Project

General

Profile

Bug #3616

SHF_GROUP sections should not be discarded via other COMDAT mechanisms

Added by Richard PALO over 7 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
2013-03-09
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

came across this with pkgsrc trying to build nettle-2.4, but am able to easily reproduce outside of pkgsrc (for example on omnios) as well as with a trivial test program, as below.

The toxique combination is gcc 4.7.2 (gcc3 and il-gcc 4.4 seem okay) with the option -ggdb3 (-g and -ggdb seem okay) and, in this case, the following (latest) ld (:

richard@devzoneX:~/src/tcov$ ld -V      
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1739 (illumos)

I never came across this issue with gcc 4.7.2 and the old /usr/bin/ld (1726)

richard@devzoneX:~/src/tcov$ uname  -a 
SunOS devzoneX 5.11 illumos-gate i86pc i386 i86pc Solaris
richard@devzoneX:~/src/tcov$ ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1739 (illumos)
richard@devzoneX:~/src/tcov$ ls
tmp.c
richard@devzoneX:~/src/tcov$ cat tmp.c 
#include <stdio.h>
int main (void)
{
        int i, total;
        total = 0;

    for (i = 0; i < 10; i++)
        {
        total += i;

                if (total != 45)
                        printf ("Failure\\n");
                else
                        printf ("Success\\n");

        return 0;
     }
}
richard@devzoneX:~/src/tcov$ gcc -v 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/lto-wrapper
Target: x86_64-sun-solaris2.11
Configured with: ../gcc-4.7.2/configure --enable-languages='c obj-c++ objc fortran c++' --enable-shared --enable-long-long --with-local-prefix=/opt/pkg/gcc47 --enable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/opt/pkg/lib ' --disable-nls --enable-__cxa_atexit --with-gxx-include-dir=/opt/pkg/gcc47/include/c++/ --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/opt/pkg/bin/gas --prefix=/opt/pkg/gcc47 --build=x86_64-sun-solaris2.11 --host=x86_64-sun-solaris2.11 --infodir=/opt/pkg/gcc47/info --mandir=/opt/pkg/gcc47/man
Thread model: posix
gcc version 4.7.2 (GCC) 
richard@devzoneX:~/src/tcov$ gcc  -fprofile-arcs -ftest-coverage tmp.c
richard@devzoneX:~/src/tcov$ gcc -ggdb -fprofile-arcs -ftest-coverage tmp.c
richard@devzoneX:~/src/tcov$ gcc -ggdb3 -fprofile-arcs -ftest-coverage tmp.c
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [31].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [33].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [35].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [37].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [39].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [41].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccO2aiQj.o: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [43].debug_macro
collect2: error: ld returned 1 exit status
richard@devzoneX:~/src/tcov$ LD_OPTIONS=-Dreloc,detail gcc -ggdb3 -fprofile-arcs -ftest-coverage tmp.c 2> dbg.log

as I mentioned, easy to reproduce with stock omnios with gcc47 installed...

got this far with the following references:
https://blogs.oracle.com/rie/entry/my_relocations_don_t_fit
http://gcc.gnu.org/ml/gcc-help/2009-02/msg00130.html

Is this a linker bug, or a gcc bug?


Files

dbg.log (228 KB) dbg.log LD_OPTIONS detail Richard PALO, 2013-03-09 05:33 AM
db1.txt (41.3 KB) db1.txt LD_OPTIONS=-Dfiles,detail,reloc,move,unused,got,sections,segments gcc -ggdb3 tmp.c -Wl,-b -Wl,-m 2> db1.txt Richard PALO, 2013-03-09 03:45 PM
db2.txt (41.3 KB) db2.txt LD_OPTIONS=-Dfiles,detail,reloc,move,unused,got,sections,segments gcc -ggdb3 tmp.c -Wl,-b 2> db2.txt Richard PALO, 2013-03-09 03:45 PM
dbomni.txt (5.57 KB) dbomni.txt LD_OPTIONS=-Dfiles,detail /opt/gcc-4.7.2/bin/gcc -v -ggdb3 tmp.c 2> dbomni.txt Richard PALO, 2013-03-10 06:45 AM

Related issues

Related to illumos gate - Bug #3638: ld confuses files with group sections and files that should lazy loadResolved2013-03-21

Actions
Related to illumos gate - Bug #3709: need sloppy relocation for GNU .debug_macroResolved2013-04-10

Actions
Related to illumos gate - Bug #5580: Sun Studio probably relies on the behaviour 3616 removedRejected2015-01-31

Actions

History

#1

Updated by Aakash Saini over 7 years ago

linker error. something wrong in stack!

need to verify with mapfile: -M <map.filename>
(map file exists under: /usr/lib/ld/)

could you update details;
1. (PIC:default)
LD_OPTIONS=-Dfiles,detail,reloc,move,unused,got,sections,segments gcc tmp.c
2. (PIC:no-special-relocation)
LD_OPTIONS=-Dfiles,detail,reloc,move,unused,got,sections,segments gcc -Wl,-b tmp.c

its probably unable to create output relocation slots.
gcc -Wl,-b -Wl,-m tmp.c (with-pic)
gcc -Wl,-m tmp.c (without-special-pic)

Its doesn't look like linker bug, but rather issues with pic-relocation-table generated by compiler. did you give any try with "gld".

#2

Updated by Aakash Saini over 7 years ago

try linking with libgcov.a:
gcc -ggdb3 -fprofile-arcs -ftest-coverage -Wl,-b -Wl,-m tmp.c -lgcov

#3

Updated by Richard PALO over 7 years ago

Aakash Saini wrote:

try linking with libgcov.a:
gcc -ggdb3 -fprofile-arcs -ftest-coverage -Wl,-b -Wl,-m tmp.c -lgcov

well, forget the gcov stuff for now as that is not the real problem (but will be the next step).
As you can see if you try the test problem as indicated above, it is the fact that gcc47 now generates .debug_macro sections and the latest /usr/bin/ld doesn't digest them very well.

$ gcc -ggdb3 tmp.c

the LD_OPTIONS output are attached

#4

Updated by Richard PALO over 7 years ago

here is verbose output with the default configuration here:


richard@devzoneX:~/src/tcov$ gcc -ggdb3 -v tmp.c 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/lto-wrapper
Target: x86_64-sun-solaris2.11
Configured with: ../gcc-4.7.2/configure --enable-languages='c obj-c++ objc fortran c++' --enable-shared --enable-long-long --with-local-prefix=/opt/pkg/gcc47 --enable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/opt/pkg/lib ' --disable-nls --enable-__cxa_atexit --with-gxx-include-dir=/opt/pkg/gcc47/include/c++/ --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/opt/pkg/bin/gas --prefix=/opt/pkg/gcc47 --build=x86_64-sun-solaris2.11 --host=x86_64-sun-solaris2.11 --infodir=/opt/pkg/gcc47/info --mandir=/opt/pkg/gcc47/man
Thread model: posix
gcc version 4.7.2 (GCC) 
COLLECT_GCC_OPTIONS='-ggdb3' '-v' '-mtune=generic' '-march=x86-64'
 /opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/cc1 -quiet -v -dD tmp.c -quiet -dumpbase tmp.c -mtune=generic -march=x86-64 -auxbase tmp -ggdb3 -version -o /var/tmp//cccHaq4X.s
GNU C (GCC) version 4.7.2 (x86_64-sun-solaris2.11)
        compiled by GNU C version 4.7.2, GMP version 5.1.1, MPFR version 3.1.1-p2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/include" 
#include "..." search starts here:
#include <...> search starts here:
 /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/include
 /opt/pkg/gcc47/include
 /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.7.2 (x86_64-sun-solaris2.11)
        compiled by GNU C version 4.7.2, GMP version 5.1.1, MPFR version 3.1.1-p2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 39d9268e6042c4f7bdbd0b31ec741e71
COLLECT_GCC_OPTIONS='-ggdb3' '-v' '-mtune=generic' '-march=x86-64'
 /opt/pkg/bin/gas -v -V -Qy -s --64 -o /var/tmp//ccdHaq4X.o /var/tmp//cccHaq4X.s
GNU assembler version 2.22 (x86_64-sun-solaris2.11) using BFD version (GNU Binutils)2.22
COMPILER_PATH=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/:/usr/ccs/bin/
LIBRARY_PATH=/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../amd64/:/lib/amd64/:/usr/lib/amd64/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-ggdb3' '-v' '-mtune=generic' '-march=x86-64'
 /opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/collect2 -V -Y P,/lib/amd64:/usr/lib/amd64 -Qy /usr/lib/amd64/crt1.o /usr/lib/amd64/crti.o /usr/lib/amd64/values-Xa.o /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/crtbegin.o -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../amd64 -L/lib/amd64 -L/usr/lib/amd64 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../.. -R /opt/pkg/gcc47/x86_64-sun-solaris2.11/lib/amd64 -R /opt/pkg/gcc47/lib/amd64 /var/tmp//ccdHaq4X.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/crtend.o /usr/lib/amd64/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1739 (illumos)
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [28].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [30].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [32].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [34].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [36].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [38].debug_macro
ld: fatal: relocation error: R_AMD64_32: file /var/tmp//ccdHaq4X.o: section [25].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [40].debug_macro
collect2: error: ld returned 1 exit status

please remind me how to override /usr/bin/ld for the gnu binutils linker gld

#5

Updated by Richard PALO over 7 years ago

BTW, I note in opengrok that I can find the DWARF files for '.debug_aranges' but not for '.debug_macro'... perhaps it is not at all supported, and now errors instead of ignoring the section encountered...

Anyway, here is another link I came across:
http://www.dwarfstd.org/ShowIssue.php?issue=110722.1

and http://www.mail-archive.com/elfutils-devel@lists.fedorahosted.org/msg01646.html

#6

Updated by Rich Lowe over 7 years ago

It almost always helps in these cases if you attach (or otherwise make available) the exact input objects being given to the link-edit. It tends to also (sadly) help if it is every object the link-edit uses (all the library .so's, the crt files, etc.)

Given that, I'll try to make some time to take a look.

#7

Updated by Richard PALO over 7 years ago

Rich Lowe wrote:

It almost always helps in these cases if you attach (or otherwise make available) the exact input objects being given to the link-edit. It tends to also (sadly) help if it is every object the link-edit uses (all the library .so's, the crt files, etc.)

Given that, I'll try to make some time to take a look.

Hi Rich, this is why I tried hard to make it absolutely trivial to reproduce... I believe the easiest is no doubt to install omnios bloody (OmniOS_Text_bloody_20130208) which has the latest ld and a gcc47 (after #pkg install developer/gcc47)

richard@omni1:~$ cat /etc/release 
  OmniOS v11 r151005
  Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
  Use is subject to license terms.

with the tmp.c found above (initial report) the attached dbomni.txt is output.

You should then have everything needed, I believe, to proceed.

Thanks.

#8

Updated by Aakash Saini over 7 years ago

Richard PALO wrote:

please remind me how to override /usr/bin/ld for the gnu binutils linker gld

LD_ALTEXEC=<path-to-gld>; LD_OPTIONS=... gcc...
it should deliver the same problem with 'gld'.

Anyway, here is another link I came across:
http://www.dwarfstd.org/ShowIssue.php?issue=110722.1

it states .debug_macinfo needs to be replaced with .debug_macro; which is not needed; add feature .debug_macro to libdwarf-v2 is what is needed under illumos/tools to support onbld.

http://src.illumos.org/source/xref/illumos-gate/usr/src/tools/ctf/dwarf/common/dwarf_init_finish.c#340
http://src.illumos.org/source/xref/illumos-gate/usr/src/tools/ctf/dwarf/common/dwarf_init_finish.c#403

if .debug_macinfo replaced with .debug_macro, it should work correctly; but keeping backward compatibility, .debug_macro needs to be added separately. rest the it should be same, except minor corrections as stated by DWARF_std.

Configured with: ../gcc-4.7.2/configure --enable-languages='c obj-c++ objc fortran c++' --enable-shared --enable-long-long --with-local-prefix=/opt/pkg/gcc47 --enable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ static-libgcc -Wl,-R/opt/pkg/lib ' --disable-nls --enable__cxa_atexit --with-gxx-include-dir=/opt/pkg/gcc47/include/c++/ --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/opt/pkg/bin/gas --prefix=/opt/pkg/gcc47 --build=x86_64-sun-solaris2.11 --host=x86_64-sun-solaris2.11 --infodir=/opt/pkg/gcc47/info --mandir=/opt/pkg/gcc47/man

config-options: http://gcc.gnu.org/install/configure.html
your gcc4.7 configuration doesn't shows: --with-dwarf2, that's why its giving the symbol section error; cause relocation slots are finding duplicate-entry, but incorrect namespace ie.debug_macinfo.

its your compiler issue. feature 'dwarf2' not supported built-in; nothing to do with linker: ld
you need to re-compiler gcc-4.7 --with-dwarf2.

#9

Updated by Richard PALO over 7 years ago

I'm not sure about all the other points, but here is the successful gld build:

richard@devzoneX:~/src/tcov$ LD_ALTEXEC=/opt/pkg/bin/gld gcc -v -ggdb3 tmp.c           
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/lto-wrapper
Target: x86_64-sun-solaris2.11
Configured with: ../gcc-4.7.2/configure --enable-languages='c obj-c++ objc fortran c++' --enable-shared --enable-long-long --with-local-prefix=/opt/pkg/gcc47 --enable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/opt/pkg/lib ' --disable-nls --enable-__cxa_atexit --with-gxx-include-dir=/opt/pkg/gcc47/include/c++/ --without-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/opt/pkg/bin/gas --prefix=/opt/pkg/gcc47 --build=x86_64-sun-solaris2.11 --host=x86_64-sun-solaris2.11 --infodir=/opt/pkg/gcc47/info --mandir=/opt/pkg/gcc47/man
Thread model: posix
gcc version 4.7.2 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-ggdb3' '-mtune=generic' '-march=x86-64'
 /opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/cc1 -quiet -v -dD tmp.c -quiet -dumpbase tmp.c -mtune=generic -march=x86-64 -auxbase tmp -ggdb3 -version -o /var/tmp//ccmba4Ng.s
GNU C (GCC) version 4.7.2 (x86_64-sun-solaris2.11)
    compiled by GNU C version 4.7.2, GMP version 5.1.1, MPFR version 3.1.1-p2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/include" 
#include "..." search starts here:
#include <...> search starts here:
 /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/include
 /opt/pkg/gcc47/include
 /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.7.2 (x86_64-sun-solaris2.11)
    compiled by GNU C version 4.7.2, GMP version 5.1.1, MPFR version 3.1.1-p2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c2bce9dfb1b39eae429556a59c99cd5b
COLLECT_GCC_OPTIONS='-v' '-ggdb3' '-mtune=generic' '-march=x86-64'
 /opt/pkg/bin/gas -v -V -Qy -s --64 -o /var/tmp//ccnba4Ng.o /var/tmp//ccmba4Ng.s
GNU assembler version 2.22 (x86_64-sun-solaris2.11) using BFD version (GNU Binutils)2.22
COMPILER_PATH=/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/:/usr/ccs/bin/
LIBRARY_PATH=/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib/amd64/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../amd64/:/lib/amd64/:/usr/lib/amd64/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib/:/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-ggdb3' '-mtune=generic' '-march=x86-64'
 /opt/pkg/gcc47/libexec/gcc/x86_64-sun-solaris2.11/4.7.2/collect2 -V -Y P,/lib/amd64:/usr/lib/amd64 -Qy /usr/lib/amd64/crt1.o /usr/lib/amd64/crti.o /usr/lib/amd64/values-Xa.o /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/crtbegin.o -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib/amd64 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../amd64 -L/lib/amd64 -L/usr/lib/amd64 -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../../../x86_64-sun-solaris2.11/lib -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/../../.. -R /opt/pkg/gcc47/x86_64-sun-solaris2.11/lib/amd64 -R /opt/pkg/gcc47/lib/amd64 /var/tmp//ccnba4Ng.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2/crtend.o /usr/lib/amd64/crtn.o
GNU ld (GNU Binutils)2.22
  Supported emulations:
   elf_x86_64_sol2
   elf_x86_64
   elf_i386_sol2
   elf_i386_ldso
   elf_i386
   elf_l1om
   elf_k1om

#10

Updated by Rich Lowe over 7 years ago

  • Category set to tools - gate/build tools

Well, steps to reproduce that involve me installing a different distribution are always going to get pushed way down the list of stuff I need to get done, but I'll try to get to it.

#11

Updated by Rich Lowe over 7 years ago

  • Assignee set to Rich Lowe
  • % Done changed from 0 to 30
  • Tags deleted (needs-triage)

Looks like it's yet more fun with COMDAT

#12

Updated by Richard PALO over 7 years ago

Rich Lowe wrote:

Well, steps to reproduce that involve me installing a different distribution are always going to get pushed way down the list of stuff I need to get done, but I'll try to get to it.

If you have an illumos instance installed with your latest linker, then the fastest may be to simply unpack the bootstrap pkgsrc kit (http://pkgsrc.smartos.org/packages/illumos/bootstrap/bootstrap-2012Q4-illumos.tar.gz) to "/" , and with your path updated (PATH=/opt/pkg/sbin:/opt/pkg/bin:$PATH) do "$ pkgin -y up" and "pkgin in gcc47" and you should be up and going.

(updated with a missing step from http://www.perkin.org.uk/posts/pkgsrc-2012Q4-packages-for-illumos.html)

#13

Updated by Rich Lowe over 7 years ago

  • Status changed from New to In Progress

This broke because I fixed gnu_comdat_sym() to actually work.

It was never doing the right thing in the first place, but we just hid the error due to #3453

#14

Updated by Rich Lowe over 7 years ago

The problem is that the SHT_GROUP sections aren't named in such a manner as to trigger sloppy relocation processing, and without sloppy relocation processing the resulting images is (rightly) seen as invalid.

A workaround is to explicitly specify "-z relaxreloc" on the ld command line. You may need to pass this through the compiler driver with, for eg, "-Wl,-z,relaxreloc"

#15

Updated by Rich Lowe over 7 years ago

  • Subject changed from gcc4.7.2 and -ggdb3 causes ld: fatal: relocation error: R_AMD64_32: file xxx: section [28].rela.debug_macro: symbol .debug_macro (section): symbol has been discarded with discarded section: [43].debug_macro to gcc 4.7 COMDAT .debug_macro groups need sloppy relocation
#16

Updated by Rich Lowe over 7 years ago

... actually. While sloppy relocations will allow the link to complete (and are why it was previously completing), why in the world are we discarding any of these comdat groups? There are no duplicates with the same signature symbols. There are no duplicates at all surely all should survive?

#17

Updated by Rich Lowe over 7 years ago

  • Subject changed from gcc 4.7 COMDAT .debug_macro groups need sloppy relocation to SHF_GROUP sections should not be discarded via other COMDAT mechanisms
  • % Done changed from 30 to 50

So, what's happening is this:

We have several group sections describing .debug_macro:

...
Group Section:  .group
     index    flags / section         signature symbol
       [0]   [ COMDAT ]               wm4.stdio_iso.h.99.3ac4f69a19c6f31d56b8e6412a91e12e
       [1]   .debug_macro [34]

Group Section:  .group
     index    flags / section         signature symbol
       [0]   [ COMDAT ]               wm4.stdio.h.158.4630a7c5bbcce1512e2d786fcbf6db85
       [1]   .debug_macro [36]

When we encounter a section within such a group, we set FLG_IS_COMDAT to indicate that the section will undergo COMDAT-like processing. Because these sections also have the same name, and the name is the key for non-GROUP comdat, we discard not only because of the group sections but also every section other than the first because of normal COMDAT.

An effective fix is that if an input section is a group member, it should never be discarded due to non-group COMDAT. I'm not sure that's a correct fix, but it works.

Another possibility is that we should stop flagging every possibly COMDAT-discardable section as FLG_IS_COMDAT, only those that are normal comdat (SUNW_COMDAT, GNU linkonce, etc.). That has implications I have not yet investigated but should.

#18

Updated by Richard PALO over 7 years ago

Hi, this test case (and nettle) seem to build fine now with:

richard@devzoneX:~/src/pkgsrc/devel/cppcheck$ /usr/bin/ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1741 (illumos)

However, I have a new situation with cppcheck-1.59 (in pkgsrc trunk)...

I'll won't be able to get back to this before this weekend (I guess with a new problem report), but I wanted to quickly indicate the problem...

g++ -I/opt/pkg/include -I/usr/include -O -I/opt/pkg/include -I/usr/include -o cppcheck cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/main.o cli/pathmatch.o cli/threadexecutor.o lib/check64bit.o lib/checkassignif.o lib/checkautovariables.o lib/checkboost.o lib/checkbufferoverrun.o lib/checkclass.o lib/checkexceptionsafety.o lib/checkinternal.o lib/checkio.o lib/checkleakautovar.o lib/checkmemoryleak.o lib/checknonreentrantfunctions.o lib/checknullpointer.o lib/checkobsoletefunctions.o lib/checkother.o lib/checkpostfixoperator.o lib/checkstl.o lib/checkuninitvar.o lib/checkunusedfunctions.o lib/checkunusedvar.o lib/cppcheck.o lib/errorlogger.o lib/executionpath.o lib/mathlib.o lib/path.o lib/preprocessor.o lib/settings.o lib/suppressions.o lib/symboldatabase.o lib/templatesimplifier.o lib/timer.o lib/token.o lib/tokenize.o lib/tokenlist.o externals/tinyxml/tinyxml2.o  -L/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2 -Wl,-R/opt/pkg/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.2 -L/opt/pkg/gcc47/lib -Wl,-R/opt/pkg/gcc47/lib -L/opt/pkg/lib -Wl,-R/opt/pkg/lib -L/usr/lib/amd64 -Wl,-R/usr/lib/amd64
Note: Writing cppcheck.1
ld: fatal: relocation error: R_AMD64_32: file externals/tinyxml/tinyxml2.o: symbol .LC4: value 0x805a9fb0 does not fit
ld: fatal: relocation error: R_AMD64_32: file externals/tinyxml/tinyxml2.o: symbol .LC3: value 0x805a9fbc does not fit
collect2: error: ld returned 1 exit status
gmake: *** [cppcheck] Error 1
gmake: *** Waiting for unfinished jobs....

#19

Updated by Rich Lowe over 7 years ago

To be clear, is that new issue completely new, and thus a separate bug, or did it used to work until you tried the linker from (presumably) my webrev?

#20

Updated by Rich Lowe over 7 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 50 to 100

Resolved in ef16f6b5

Also available in: Atom PDF