aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-bfd.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-04-30 18:27:32 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-04-30 18:27:32 +0000
commit0672748ac053cc4f8159af0d21ca88ae8b3778e6 (patch)
tree6ce1177f0a49e04ca388d25edc23db44dd3fd1b3 /bfd/elf-bfd.h
parent705b5767b7302e9fdd64d2a2ec5942ff22975a98 (diff)
downloadgdb-0672748ac053cc4f8159af0d21ca88ae8b3778e6.zip
gdb-0672748ac053cc4f8159af0d21ca88ae8b3778e6.tar.gz
gdb-0672748ac053cc4f8159af0d21ca88ae8b3778e6.tar.bz2
Remove relocation against discarded sections for relocatable link.
bfd/ 2010-04-30 H.J. Lu <hongjiu.lu@intel.com> PR ld/11542 * elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): New. * elf32-i386.c (elf_i386_relocate_section): Use it. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. ld/testsuite/ 2010-04-30 H.J. Lu <hongjiu.lu@intel.com> PR ld/11542 * ld-elf/discard.ld: New. * ld-elf/discard1.d: Likewise. * ld-elf/discard1.s: Likewise. * ld-elf/discard2.d: Likewise. * ld-elf/discard2.s: Likewise. * ld-elf/discard3.d: Likewise.
Diffstat (limited to 'bfd/elf-bfd.h')
-rw-r--r--bfd/elf-bfd.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 0c975dc..226b95f 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2328,6 +2328,48 @@ extern asection _bfd_elf_large_com_section;
} \
while (0)
+/* This macro is to avoid lots of duplicated code in the body of the
+ loop over relocations in xxx_relocate_section() in the various
+ elfxx-xxxx.c files.
+
+ Handle relocations against symbols from removed linkonce sections,
+ or sections discarded by a linker script. When doing a relocatable
+ link, we remove such relocations. Otherwise, we just want the
+ section contents zeroed and avoid any special processing. */
+#define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section, \
+ rel, relend, howto, contents) \
+ { \
+ if (info->relocatable \
+ && (input_section->flags & SEC_DEBUGGING)) \
+ { \
+ /* Only remove relocations in debug sections since other \
+ sections may require relocations. */ \
+ Elf_Internal_Shdr *rel_hdr; \
+ \
+ rel_hdr = &elf_section_data (input_section->output_section)->rel_hdr; \
+ \
+ /* Avoid empty output section. */ \
+ if (rel_hdr->sh_size > rel_hdr->sh_entsize) \
+ { \
+ rel_hdr->sh_size -= rel_hdr->sh_entsize; \
+ rel_hdr = &elf_section_data (input_section)->rel_hdr; \
+ rel_hdr->sh_size -= rel_hdr->sh_entsize; \
+ \
+ memmove (rel, rel + 1, (relend - rel) * sizeof (*rel)); \
+ \
+ input_section->reloc_count--; \
+ relend--; \
+ rel--; \
+ continue; \
+ } \
+ } \
+ \
+ _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); \
+ rel->r_info = 0; \
+ rel->r_addend = 0; \
+ continue; \
+ }
+
/* Will a symbol be bound to the the definition within the shared
library, if any. A unique symbol can never be bound locally. */
#define SYMBOLIC_BIND(INFO, H) \