Bug 6996 - Regression: linking fails on objects in discarded section of *.o files
Summary: Regression: linking fails on objects in discarded section of *.o files
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-30 14:13 UTC by James Richard Tyrer
Modified: 2020-01-31 07:02 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Last reconfirmed:


Attachments
readelf of object file (1.53 KB, text/plain)
2008-11-07 16:50 UTC, James Richard Tyrer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Richard Tyrer 2008-10-30 14:13:40 UTC
Research on Google indicates that this problem has occurred before.

When building llvm-2.3

http://www.llvm.org/releases/

with the patch from OpenGTL:

http://www.opengtl.org/Download.html

Using GCC-4.3.2 and BinUtils-2.19, linking fails with error:

make[2]: Entering directory `/usr/src/llvm-2.3/tools/llc'
llvm[2]: Linking Release executable llc (without symbols)
`.L1297' referenced in section 
`.gnu.linkonce.r._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o): 
defined in discarded section 
`.gnu.linkonce.t._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o)
`.L1298' referenced in section 
`.gnu.linkonce.r._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o): 
defined in discarded section 
`.gnu.linkonce.t._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o)
`.L1298' referenced in section 
`.gnu.linkonce.r._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o): 
defined in discarded section 
`.gnu.linkonce.t._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o)
`.L1299' referenced in section 
`.gnu.linkonce.r._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o): 
defined in discarded section 
`.gnu.linkonce.t._ZNK4llvm14TargetLowering19ValueTypeActionImpl13getTypeActionEj' 
of /usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a(TargetLowering.o)

and a lot more of similar errors.
Comment 1 H.J. Lu 2008-11-07 14:39:27 UTC
Please show "readelf -Sg TargetLowering.o" in
/usr/src/llvm-2.3/Release/lib/libLLVMSelectionDAG.a.
Comment 2 James Richard Tyrer 2008-11-07 16:50:57 UTC
Created attachment 3048 [details]
readelf of object file
Comment 3 H.J. Lu 2008-11-07 17:22:55 UTC
(In reply to comment #2)
> Created an attachment (id=3048)
> readelf of object file
> 

There is:

There are no section groups in this file.

Why doesn't it use COMDAT group with gcc 4.3.2 and binutils 2.19. The
correct .o files should use COMDAT group for linkonce sections:

[hjl@gnu-26 src]$ readelf -Sg valarray-inst.o
There are 60 section headers, starting at offset 0x83e8:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .group            GROUP            0000000000000000  00000040
       0000000000000008  0000000000000004          58    41     4
  [ 2] .group            GROUP            0000000000000000  00000048
       0000000000000008  0000000000000004          58    43     4
  [ 3] .group            GROUP            0000000000000000  00000050
       0000000000000008  0000000000000004          58    44     4
  [ 4] .group            GROUP            0000000000000000  00000058
       0000000000000008  0000000000000004          58    45     4
  [ 5] .group            GROUP            0000000000000000  00000060
       0000000000000008  0000000000000004          58    48     4
  [ 6] .group            GROUP            0000000000000000  00000068
       0000000000000008  0000000000000004          58    50     4
  [ 7] .group            GROUP            0000000000000000  00000070
       0000000000000008  0000000000000004          58    51     4
  [ 8] .group            GROUP            0000000000000000  00000078
       0000000000000008  0000000000000004          58    53     4
  [ 9] .group            GROUP            0000000000000000  00000080
       0000000000000008  0000000000000004          58    54     4
  [10] .group            GROUP            0000000000000000  00000088
       0000000000000008  0000000000000004          58    55     4
  [11] .text             PROGBITS         0000000000000000  00000090
       0000000000000000  0000000000000000  AX       0     0     4
  [12] .data             PROGBITS         0000000000000000  00000090
       0000000000000000  0000000000000000  WA       0     0     4
  [13] .bss              NOBITS           0000000000000000  00000090
       0000000000000000  0000000000000000  WA       0     0     4
  [14] .debug_abbrev     PROGBITS         0000000000000000  00000090
       0000000000000529  0000000000000000           0     0     1
  [15] .debug_info       PROGBITS         0000000000000000  000005b9
       000000000000343f  0000000000000000           0     0     1
  [16] .rela.debug_info  RELA             0000000000000000  00009a68
       00000000000044b8  0000000000000018          58    15     8
  [17] .debug_line       PROGBITS         0000000000000000  000039f8
       0000000000000746  0000000000000000           0     0     1
  [18] .rela.debug_line  RELA             0000000000000000  0000df20
       0000000000000138  0000000000000018          58    17     8
  [19] .text._ZSt15__val PROGBITS         0000000000000000  00004140
       000000000000001a  0000000000000000 AXG       0     0     16
  [20] .text._ZNKSt8vala PROGBITS         0000000000000000  00004160
       0000000000000004  0000000000000000 AXG       0     0     16
  [21] .text._ZNSt8valar PROGBITS         0000000000000000  00004170
       000000000000000d  0000000000000000 AXG       0     0     16
  [22] .text._ZNSt8valar PROGBITS         0000000000000000  00004180
       000000000000004e  0000000000000000 AXG       0     0     16
  [23] .rela.text._ZNSt8 RELA             0000000000000000  0000e058
       0000000000000030  0000000000000018          58    22     8
  [24] .text._ZSt15__val PROGBITS         0000000000000000  000041d0
       0000000000000016  0000000000000000 AXG       0     0     16
  [25] .rela.text._ZSt15 RELA             0000000000000000  0000e088
       0000000000000018  0000000000000018          58    24     8
  [26] .text._ZNSt8valar PROGBITS         0000000000000000  000041f0
       0000000000000052  0000000000000000 AXG       0     0     16
  [27] .rela.text._ZNSt8 RELA             0000000000000000  0000e0a0
       0000000000000030  0000000000000018          58    26     8
  [28] .text._ZNSt8valar PROGBITS         0000000000000000  00004250
       0000000000000009  0000000000000000 AXG       0     0     16
  [29] .rela.text._ZNSt8 RELA             0000000000000000  0000e0d0
       0000000000000018  0000000000000018          58    28     8
  [30] .text._ZNSt8valar PROGBITS         0000000000000000  00004260
       0000000000000009  0000000000000000 AXG       0     0     16
  [31] .rela.text._ZNSt8 RELA             0000000000000000  0000e0e8
       0000000000000018  0000000000000018          58    30     8
  [32] .text._ZNSt8valar PROGBITS         0000000000000000  00004270
       0000000000000052  0000000000000000 AXG       0     0     16
  [33] .rela.text._ZNSt8 RELA             0000000000000000  0000e100
       0000000000000030  0000000000000018          58    32     8
  [34] .text._ZNSt8valar PROGBITS         0000000000000000  000042d0
       000000000000004e  0000000000000000 AXG       0     0     16
  [35] .rela.text._ZNSt8 RELA             0000000000000000  0000e130
       0000000000000030  0000000000000018          58    34     8
  [36] .text._ZSt17__gsl PROGBITS         0000000000000000  00004320
       0000000000000157  0000000000000000  AX       0     0     16
  [37] .rela.text._ZSt17 RELA             0000000000000000  0000e160
       0000000000000048  0000000000000018          58    36     8
  [38] .text._ZNSt6gslic PROGBITS         0000000000000000  00004480
       000000000000013a  0000000000000000  AX       0     0     16
  [39] .rela.text._ZNSt6 RELA             0000000000000000  0000e1a8
       0000000000000108  0000000000000018          58    38     8
  [40] .gcc_except_table PROGBITS         0000000000000000  000045ba
       000000000000001e  0000000000000000   A       0     0     1
  [41] .text._ZNSt6gslic PROGBITS         0000000000000000  000045e0
       000000000000013a  0000000000000000  AX       0     0     16
  [42] .rela.text._ZNSt6 RELA             0000000000000000  0000e2b0
       0000000000000108  0000000000000018          58    41     8
  [43] .gcc_except_table PROGBITS         0000000000000000  0000471a
       000000000000001e  0000000000000000   A       0     0     1
  [44] .debug_loc        PROGBITS         0000000000000000  00004738
       0000000000000875  0000000000000000           0     0     1
  [45] .rela.debug_loc   RELA             0000000000000000  0000e3b8
       0000000000000ed0  0000000000000018          58    44     8
  [46] .debug_pubnames   PROGBITS         0000000000000000  00004fad
       0000000000000220  0000000000000000           0     0     1
  [47] .rela.debug_pubna RELA             0000000000000000  0000f288
       0000000000000018  0000000000000018          58    46     8
  [48] .debug_aranges    PROGBITS         0000000000000000  000051cd
       00000000000000f0  0000000000000000           0     0     1
  [49] .rela.debug_arang RELA             0000000000000000  0000f2a0
       0000000000000150  0000000000000018          58    48     8
  [50] .debug_ranges     PROGBITS         0000000000000000  000052bd
       0000000000000970  0000000000000000           0     0     1
  [51] .rela.debug_range RELA             0000000000000000  0000f3f0
       00000000000014d0  0000000000000018          58    50     8
  [52] .debug_str        PROGBITS         0000000000000000  00005c2d
       0000000000002247  0000000000000001  MS       0     0     1
  [53] .comment          PROGBITS         0000000000000000  00007e74
       0000000000000042  0000000000000000           0     0     1
  [54] .note.GNU-stack   PROGBITS         0000000000000000  00007eb6
       0000000000000000  0000000000000000           0     0     1
  [55] .eh_frame         PROGBITS         0000000000000000  00007eb8
       00000000000001c0  0000000000000000   A       0     0     8
  [56] .rela.eh_frame    RELA             0000000000000000  000108c0
       0000000000000198  0000000000000018          58    55     8
  [57] .shstrtab         STRTAB           0000000000000000  00008078
       000000000000036c  0000000000000000           0     0     1
  [58] .symtab           SYMTAB           0000000000000000  000092e8
       00000000000005a0  0000000000000018          59    41     8
  [59] .strtab           STRTAB           0000000000000000  00009888
       00000000000001dd  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

COMDAT group section [    1] `.group' [_ZSt15__valarray_fillImEvPT_mRKS0_]
contains 1 sections:
   [Index]    Name
   [   19]   .text._ZSt15__valarray_fillImEvPT_mRKS0_

COMDAT group section [    2] `.group' [_ZNKSt8valarrayImE4sizeEv] contains 1
sections:
   [Index]    Name
   [   20]   .text._ZNKSt8valarrayImE4sizeEv

COMDAT group section [    3] `.group' [_ZNSt8valarrayImEixEm] contains 1 sections:
   [Index]    Name
   [   21]   .text._ZNSt8valarrayImEixEm

COMDAT group section [    4] `.group' [_ZNSt8valarrayImEC2Em] contains 1 sections:
   [Index]    Name
   [   22]   .text._ZNSt8valarrayImEC2Em

COMDAT group section [    5] `.group' [_ZSt15__valarray_copyImEvPKT_mPS0_]
contains 1 sections:
   [Index]    Name
   [   24]   .text._ZSt15__valarray_copyImEvPKT_mPS0_

COMDAT group section [    6] `.group' [_ZNSt8valarrayImEC1ERKS0_] contains 1
sections:
   [Index]    Name
   [   26]   .text._ZNSt8valarrayImEC1ERKS0_

COMDAT group section [    7] `.group' [_ZNSt8valarrayImED1Ev] contains 1 sections:
   [Index]    Name
   [   28]   .text._ZNSt8valarrayImED1Ev

COMDAT group section [    8] `.group' [_ZNSt8valarrayImED2Ev] contains 1 sections:
   [Index]    Name
   [   30]   .text._ZNSt8valarrayImED2Ev

COMDAT group section [    9] `.group' [_ZNSt8valarrayImEC2ERKS0_] contains 1
sections:
   [Index]    Name
   [   32]   .text._ZNSt8valarrayImEC2ERKS0_

COMDAT group section [   10] `.group' [_ZNSt8valarrayImEC1Em] contains 1 sections:
   [Index]    Name
   [   34]   .text._ZNSt8valarrayImEC1Em
[hjl@gnu-26 src]$ 
Comment 4 Alan Modra 2009-01-13 07:22:08 UTC
There's a good chance this is fixed with the following patch:
2009-01-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* elflink.c (_bfd_elf_section_already_linked): Handle g++-3.4
	relocations in `.gnu.linkonce.r.*' referencing its `.gnu.linkonce.t.*'.

Please test and close the bug if fixed.
Comment 5 Alan Modra 2020-01-31 07:02:50 UTC
Presumed fixed.