summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2008-09-17 07:50:29 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2008-09-17 07:50:29 +0000
commit2a7b2e88e38cbd83225e9c3b28a990de56dccef7 (patch)
tree5a8ae06b9f452694184c05f9b9576ccc36c6266a
parent32649b97b910a25743777a9ef0c7ba2a0bae3e35 (diff)
downloadppe42-binutils-2a7b2e88e38cbd83225e9c3b28a990de56dccef7.tar.gz
ppe42-binutils-2a7b2e88e38cbd83225e9c3b28a990de56dccef7.zip
bfd/
PR 6893 - Do not consider FDEs for discarded sections as invalid. * elf-eh-frame.c (_bfd_elf_parse_eh_frame): New REQUIRE_CLEARED_RELOCS. Consider FDEs with cleared relocations as valid and ignorable. ld/testsuite/ * ld-elf/eh-group.exp, ld-elf/eh-group1.s, ld-elf/eh-group2.s: New test. binutils/ Suppress warnings on NONE relocations to discarded sections. * readelf.c (is_none_reloc): New function. (debug_apply_relocations): Ignore is_none_reloc() relocations.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf-eh-frame.c33
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/readelf.c50
-rw-r--r--ld/testsuite/ChangeLog4
-rw-r--r--ld/testsuite/ld-elf/eh-group.exp51
-rw-r--r--ld/testsuite/ld-elf/eh-group1.s6
-rw-r--r--ld/testsuite/ld-elf/eh-group2.s4
8 files changed, 156 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 705c6f7061..97c46de6e4 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-17 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR 6893 - Do not consider FDEs for discarded sections as invalid.
+ * elf-eh-frame.c (_bfd_elf_parse_eh_frame): New REQUIRE_CLEARED_RELOCS.
+ Consider FDEs with cleared relocations as valid and ignorable.
+
2008-09-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/6877
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 7151a39763..579a6b8967 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -549,6 +549,16 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
< (bfd_size_type) ((buf) - ehbuf))) \
cookie->rel++
+#define REQUIRE_CLEARED_RELOCS(buf) \
+ while (cookie->rel < cookie->relend \
+ && (cookie->rel->r_offset \
+ < (bfd_size_type) ((buf) - ehbuf))) \
+ { \
+ REQUIRE (cookie->rel->r_info == 0); \
+ REQUIRE (cookie->rel->r_addend == 0); \
+ cookie->rel++; \
+ }
+
#define GET_RELOC(buf) \
((cookie->rel < cookie->relend \
&& (cookie->rel->r_offset \
@@ -766,9 +776,14 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
/* Chain together the FDEs for each section. */
rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie);
- REQUIRE (rsec && rsec->owner == abfd);
- this_inf->u.fde.next_for_section = elf_fde_list (rsec);
- elf_fde_list (rsec) = this_inf;
+ /* RSEC will be NULL if FDE was cleared out as it was belonging to
+ a discarded SHT_GROUP. */
+ if (rsec)
+ {
+ REQUIRE (rsec->owner == abfd);
+ this_inf->u.fde.next_for_section = elf_fde_list (rsec);
+ elf_fde_list (rsec) = this_inf;
+ }
/* Skip the initial location and address range. */
start = buf;
@@ -801,7 +816,17 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
insns = buf;
buf = last_fde + 4 + hdr_length;
- SKIP_RELOCS (buf);
+
+ /* Cleared FDE? The instructions will not be cleared but verify all
+ the relocation entries for them are cleared. */
+ if (rsec == NULL)
+ {
+ REQUIRE_CLEARED_RELOCS (buf);
+ }
+ else
+ {
+ SKIP_RELOCS (buf);
+ }
}
/* Try to interpret the CFA instructions and find the first
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 73bb1979e6..cdff4b06f1 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2008-09-17 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Suppress warnings on NONE relocations to discarded sections.
+ * readelf.c (is_none_reloc): New function.
+ (debug_apply_relocations): Ignore is_none_reloc() relocations.
+
2008-09-11 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix loading large elf64 binaries on 32bit hosts.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 9f1008ccf3..2d356a6962 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -8284,6 +8284,53 @@ is_16bit_abs_reloc (unsigned int reloc_type)
}
}
+/* Returns TRUE iff RELOC_TYPE is a NONE relocation used for discarded
+ relocation entries (possibly formerly used for SHT_GROUP sections). */
+
+static bfd_boolean
+is_none_reloc (unsigned int reloc_type)
+{
+ switch (elf_header.e_machine)
+ {
+ case EM_68K:
+ return reloc_type == 0; /* R_68K_NONE. */
+ case EM_386:
+ return reloc_type == 0; /* R_386_NONE. */
+ case EM_SPARC32PLUS:
+ case EM_SPARCV9:
+ case EM_SPARC:
+ return reloc_type == 0; /* R_SPARC_NONE. */
+ case EM_MIPS:
+ return reloc_type == 0; /* R_MIPS_NONE. */
+ case EM_PARISC:
+ return reloc_type == 0; /* R_PARISC_NONE. */
+ case EM_ALPHA:
+ return reloc_type == 0; /* R_ALPHA_NONE. */
+ case EM_PPC:
+ return reloc_type == 0; /* R_PPC_NONE. */
+ case EM_PPC64:
+ return reloc_type == 0; /* R_PPC64_NONE. */
+ case EM_ARM:
+ return reloc_type == 0; /* R_ARM_NONE. */
+ case EM_IA_64:
+ return reloc_type == 0; /* R_IA64_NONE. */
+ case EM_SH:
+ return reloc_type == 0; /* R_SH_NONE. */
+ case EM_S390_OLD:
+ case EM_S390:
+ return reloc_type == 0; /* R_390_NONE. */
+ case EM_CRIS:
+ return reloc_type == 0; /* R_CRIS_NONE. */
+ case EM_X86_64:
+ return reloc_type == 0; /* R_X86_64_NONE. */
+ case EM_MN10300:
+ return reloc_type == 0; /* R_MN10300_NONE. */
+ case EM_M32R:
+ return reloc_type == 0; /* R_M32R_NONE. */
+ }
+ return FALSE;
+}
+
/* Uncompresses a section that was compressed using zlib, in place.
* This is a copy of bfd_uncompress_section_contents, in bfd/compress.c */
@@ -8419,6 +8466,9 @@ debug_apply_relocations (void *file,
reloc_type = get_reloc_type (rp->r_info);
+ if (is_none_reloc (reloc_type))
+ continue;
+
if (is_32bit_abs_reloc (reloc_type)
|| is_32bit_pcrel_reloc (reloc_type))
reloc_size = 4;
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 8065033223..da090bc6b3 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2008-09-17 Jan Kratochvil <jan.kratochvil@redhat.com>
+ * ld-elf/eh-group.exp, ld-elf/eh-group1.s, ld-elf/eh-group2.s: New test.
+
+2008-09-17 Jan Kratochvil <jan.kratochvil@redhat.com>
+
Fix testcases compilation failures due to unused variables.
* ld-elfcomm/common1b.c (dummy1): Mark the variable for GCC as USED.
* ld-shared/main.c (main): Move the P variable only to the places where
diff --git a/ld/testsuite/ld-elf/eh-group.exp b/ld/testsuite/ld-elf/eh-group.exp
new file mode 100644
index 0000000000..64d2cf409f
--- /dev/null
+++ b/ld/testsuite/ld-elf/eh-group.exp
@@ -0,0 +1,51 @@
+# Expect script for .eh_frame entries to a removed section.
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+#
+# Written by Jan Kratochvil (jan.kratochvil@redhat.com)
+#
+# .eh_frame with relocations to a removed (group) section did result to:
+# error in tmpdir/eh-group.o(.eh_frame); no .eh_frame_hdr table will be created.
+# The purpose of this test is to merge two .o files with -r and then link this
+# merged file (containing a discarded R_X86_64_NONE relocation) to the final
+# executable trying to create .eh_frame_hdr. It needs a separate .exp file due
+# to the requirement of two `ld' runs.
+
+# Exclude non-ELF targets.
+
+if ![is_elf_format] {
+ return
+}
+
+set build_tests_ld {
+ {"Build eh-group1.o"
+ "-r" ""
+ {eh-group1.s eh-group2.s} {} "eh-group.o"}
+}
+
+run_ld_link_tests $build_tests_ld
+
+set testname "Link eh-group.o to eh-group"
+if [ld_simple_link $ld "tmpdir/eh-group" "-e _start tmpdir/eh-group.o"] {
+ pass $testname
+} else {
+ fail $testname
+}
diff --git a/ld/testsuite/ld-elf/eh-group1.s b/ld/testsuite/ld-elf/eh-group1.s
new file mode 100644
index 0000000000..ebbe31842d
--- /dev/null
+++ b/ld/testsuite/ld-elf/eh-group1.s
@@ -0,0 +1,6 @@
+ .section sect, "axG", @progbits, sectgroup, comdat
+ .global _start
+_start:
+ .cfi_startproc
+ .skip 16
+ .cfi_endproc
diff --git a/ld/testsuite/ld-elf/eh-group2.s b/ld/testsuite/ld-elf/eh-group2.s
new file mode 100644
index 0000000000..a589896baa
--- /dev/null
+++ b/ld/testsuite/ld-elf/eh-group2.s
@@ -0,0 +1,4 @@
+ .section sect, "axG", @progbits, sectgroup, comdat
+ .cfi_startproc
+ .skip 16
+ .cfi_endproc
OpenPOWER on IntegriCloud