https://sourceware.org/bugzilla/show_bug.cgi?id=25020
--- Comment #2 from Fangrui Song <i at maskray dot me> --- I mean the error should probably be issued for any discarded section. .globl _start _start: call .foo1 call baz0 call baz1 .section .foo0,"a" .byte 0 .section .foo1,"a" .byte 0 ## The linked-to section of the second input section is discarded. .section .baz,"ao",@progbits,.foo1,unique,0 baz0: .byte 0 .section .baz,"ao",@progbits,.foo0,unique,1 baz1: .byte 1 % llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o % ld.bfd a.o --gc-sections -o a # no error, but probably should have one. % readelf -S a # sh_link(.baz) = .foo1 ; it seems the first non-discarded input section is picked. ... Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 [ 1] .note.gnu.property NOTE 0000000000400120 000120 000020 00 A 0 0 8 [ 2] .text PROGBITS 0000000000401000 001000 00000f 00 AX 0 0 4 [ 3] .foo1 PROGBITS 0000000000402000 002000 000001 00 A 0 0 1 [ 4] .baz PROGBITS 0000000000402001 002001 000002 00 AL 3 0 1 The ELF spec does not seem to describe sh_link of the output section. GNU ld appears to use the first non-discarded input section. This is fine (lld does the same). -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils