https://sourceware.org/bugzilla/show_bug.cgi?id=19446
Bug ID: 19446 Summary: BFD linker discards section without alloc section attribute under certain conditions Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: xinliangli at gmail dot com Target Milestone: --- If a section is not marked with SHF_ALLOC attribute and when --gc-sections is on, the BFD linker only keeps it if the section has no references to other symbols. If there is reference to other symbols, the linker will garbage collect it. By comparison, Gold linker does not garbage collect such sections regardless of the contents of the section. Example: t.s gcc -fuse-ld=bfd -Wl,--gc-sections t.s objdump -h a.out |grep UNREF Changing the assembly file a little by making unref initialized to 0, linker will keep the UNREF section. The version of the linker tested is 2.24. .file "unref2.c" .comm g0,4,4 .globl unref .section UNREF,"",@progbits .align 8 .type unref, @object .size unref, 8 unref: .quad g0 .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 movl $1, %eax popq %rbp .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4" .section .note.GNU-stack,"",@progbits -- 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