From 16583161e14cbe747e78da035790c48951884556 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 7 Jan 2010 13:44:37 +0000 Subject: [PATCH] Always keep SHT_NOTE sections bfd/ 2010-01-07 H.J. Lu PR ld/11143 * elflink.c (elf_gc_sweep): Keep SHT_NOTE section. ld/testsuite/ 2010-01-07 H.J. Lu PR ld/11143 * ld-gc/gc.exp: Run abi-note. * ld-gc/abi-note.d: New. * ld-gc/abi-note.s: Likewise. --- bfd/ChangeLog | 5 +++++ bfd/elflink.c | 7 ++++--- ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-gc/abi-note.d | 8 ++++++++ ld/testsuite/ld-gc/abi-note.s | 15 +++++++++++++++ ld/testsuite/ld-gc/gc.exp | 3 ++- 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 ld/testsuite/ld-gc/abi-note.d create mode 100644 ld/testsuite/ld-gc/abi-note.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4d0db31debd..01950b4fc0e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2010-01-07 H.J. Lu + + PR ld/11143 + * elflink.c (elf_gc_sweep): Keep SHT_NOTE section. + 2010-01-04 Daniel Gutson * bfd.m4 (BFD_HAVE_SYS_PROCFS_TYPE): Define _STRUCTURE_PROC diff --git a/bfd/elflink.c b/bfd/elflink.c index bbdfe5e91f1..284bff14d7a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1,6 +1,6 @@ /* ELF linking support for BFD. Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009 + 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -11527,9 +11527,10 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info) o->gc_mark = first->gc_mark; } else if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0 - || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0) + || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0 + || elf_section_data (o)->this_hdr.sh_type == SHT_NOTE) { - /* Keep debug and special sections. */ + /* Keep debug, special and SHT_NOTE sections. */ o->gc_mark = 1; } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 4a2a6da1165..3320c13dbb8 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-01-07 H.J. Lu + + PR ld/11143 + * ld-gc/gc.exp: Run abi-note. + + * ld-gc/abi-note.d: New. + * ld-gc/abi-note.s: Likewise. For older changes see ChangeLog-2009 diff --git a/ld/testsuite/ld-gc/abi-note.d b/ld/testsuite/ld-gc/abi-note.d new file mode 100644 index 00000000000..e802fe5ec48 --- /dev/null +++ b/ld/testsuite/ld-gc/abi-note.d @@ -0,0 +1,8 @@ +#name: --gc-sections with note section +#ld: --gc-sections -e _start +#readelf: -S --wide +#target: *-*-linux* + +#... +.* .note.ABI-tag[ ]+NOTE.* +#... diff --git a/ld/testsuite/ld-gc/abi-note.s b/ld/testsuite/ld-gc/abi-note.s new file mode 100644 index 00000000000..22536c0f831 --- /dev/null +++ b/ld/testsuite/ld-gc/abi-note.s @@ -0,0 +1,15 @@ + .text + .global _start +_start: + .long 1 + + .section ".note.ABI-tag", "a" + .p2align 2 + .long 1f - 0f /* name length */ + .long 3f - 2f /* data length */ + .long 1 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: .p2align 2 +2: .long 1 + .long 2 +3: .p2align 2 /* pad out section */ diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp index c85d4f2f33a..36df2338ebd 100644 --- a/ld/testsuite/ld-gc/gc.exp +++ b/ld/testsuite/ld-gc/gc.exp @@ -1,5 +1,5 @@ # Expect script for ld-gc tests -# Copyright 2008, 2009 +# Copyright 2008, 2009, 2010 # Free Software Foundation, Inc. # # This file is part of the GNU Binutils. @@ -90,3 +90,4 @@ test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main" test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func" run_dump_test "noent" +run_dump_test "abi-note" -- 2.30.2