diff options
author | Jakub Jelinek <jakub@redhat.com> | 2001-08-23 15:14:18 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2001-08-23 15:14:18 +0000 |
commit | db6751f2e760a6a65ab297b83942951b9aea3b79 (patch) | |
tree | 54f3e4f79ab1a218ff657703ad47ff331d756dd2 /bfd/elf32-i386.c | |
parent | da4d4077bcdd5d25d56c0d216a2ff9009cb60649 (diff) | |
download | gdb-db6751f2e760a6a65ab297b83942951b9aea3b79.zip gdb-db6751f2e760a6a65ab297b83942951b9aea3b79.tar.gz gdb-db6751f2e760a6a65ab297b83942951b9aea3b79.tar.bz2 |
* elf-bfd.h (enum elf_reloc_type_class): New.
(struct elf_backend_data): Add elf_backend_reloc_type_class.
(_bfd_elf_reloc_type_class): New.
* elfxx-target.h (elf_backend_reloc_type_class): Define.
(elfNN_bed): Add elf_backend_reloc_type_class.
* elf.c (_bfd_elf_reloc_type_class): New.
* elf32-i386.c (elf_i386_check_relocs): Set DF_TEXTREL if the reloc
is against read-only section.
(elf_i386_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(elf_i386_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elf32-sparc.c (elf32_sparc_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section.
(elf32_sparc_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(elf32_sparc_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elf64-sparc.c (sparc64_elf_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section.
(sparc64_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(sparc64_elf_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elfxx-ia64.c (struct elfNN_ia64_link_hash_table): Add reltext field.
(elfNN_ia64_hash_table_create): Clear ia64_info.
(get_reloc_section): Set DF_TEXTREL if the reloc is against read-only
section.
(elfNN_ia64_size_dynamic_sections): Use ia64_info->reltext flag
instead of looking up section names for DT_TEXTREL.
(elfNN_ia64_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elflink.h (size_dynamic_sections): Add spare DT_NULL tags.
(struct elf_link_sort_rela): New.
(elf_link_sort_cmp1, elf_link_sort_cmp2, elf_link_sort_relocs): New.
(elf_bfd_final_link): Call elf_link_sort_relocs.
Convert one spare DT_NULL into DT_RELCOUNT resp. DT_RELACOUNT if
necessary.
* bfdlink.h (struct bfd_link_info): Add combreloc and
spare_dynamic_tags fields.
* emultempl/elf32.em (place_orphan): Place orphan .rel* sections
into .rel.dyn resp. .rela.dyn if combreloc.
(get_script): If .x linker script is equal to .xn, only put it
once into the binary.
Add .xc and .xsc scripts.
(parse_args): Handle -z combreloc and -z nocombreloc.
* scripttempl/elf.sc (.rela.sbss): Fix a typo.
For .xc and .xsc scripts put all .rel* or .rela* input sections
but .rel*.plt and PLT-like sections into .rel.dyn resp. .rela.dyn.
* genscripts.sh (GENERATE_COMBRELOC_SCRIPT): Set if SCRIPT_NAME
is elf.
Strip trailing whitespace from script.
Generate .xc and .xsc scripts if requested.
* ldmain.c (main): Initialize link_info.combreloc and
link_info.spare_dynamic_tags.
* lexsup.c (OPTION_SPARE_DYNAMIC_TAGS): Define.
(ld_options): Add --spare-dynamic-tags option.
(parse_args): Likewise.
* ld.texinfo: Document -z combreloc and -z nocombreloc.
* ldint.texinfo: Document .xc and .xsc linker scripts.
* NEWS: Add notes about -z combreloc and SHF_MERGE.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r-- | bfd/elf32-i386.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 00ca185..8c49559 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -63,6 +63,7 @@ static boolean elf_i386_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); static boolean elf_i386_fake_sections PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); +static enum elf_reloc_type_class elf_i386_reloc_type_class PARAMS ((int)); #define USE_REL 1 /* 386 uses REL relocations instead of RELA */ @@ -767,6 +768,8 @@ elf_i386_check_relocs (abfd, info, sec, relocs) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return false; } + if (sec->flags & SEC_READONLY) + info->flags |= DF_TEXTREL; } sreloc->_raw_size += sizeof (Elf32_External_Rel); @@ -1243,14 +1246,13 @@ allocate_plt_and_got_and_discard_relocs (h, inf) static boolean elf_i386_size_dynamic_sections (output_bfd, info) - bfd *output_bfd; + bfd *output_bfd ATTRIBUTE_UNUSED; struct bfd_link_info *info; { struct elf_i386_link_hash_table *htab; bfd *dynobj; asection *s; boolean relocs; - boolean reltext; bfd *i; htab = elf_i386_hash_table (info); @@ -1315,7 +1317,6 @@ elf_i386_size_dynamic_sections (output_bfd, info) /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ relocs = false; - reltext = false; for (s = dynobj->sections; s != NULL; s = s->next) { if ((s->flags & SEC_LINKER_CREATED) == 0) @@ -1344,29 +1345,8 @@ elf_i386_size_dynamic_sections (output_bfd, info) } else { - asection *target; - - /* Remember whether there are any reloc sections other - than .rel.plt. */ if (s != htab->srelplt) - { - const char *outname; - - relocs = true; - - /* If this relocation section applies to a read only - section, then we probably need a DT_TEXTREL - entry. The entries in the .rel.plt section - really apply to the .got section, which we - created ourselves and so know is not readonly. */ - outname = bfd_get_section_name (output_bfd, - s->output_section); - target = bfd_get_section_by_name (output_bfd, outname + 4); - if (target != NULL - && (target->flags & SEC_READONLY) != 0 - && (target->flags & SEC_ALLOC) != 0) - reltext = true; - } + relocs = true; /* We use the reloc_count field as a counter if we need to copy relocs into the output file. */ @@ -1426,11 +1406,10 @@ elf_i386_size_dynamic_sections (output_bfd, info) return false; } - if (reltext) + if ((info->flags & DF_TEXTREL) != 0) { if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0)) return false; - info->flags |= DF_TEXTREL; } } @@ -2215,6 +2194,22 @@ elf_i386_fake_sections (abfd, hdr, sec) return true; } +static enum elf_reloc_type_class +elf_i386_reloc_type_class (type) + int type; +{ + switch (type) + { + case R_386_RELATIVE: + return reloc_class_relative; + case R_386_JUMP_SLOT: + return reloc_class_plt; + case R_386_COPY: + return reloc_class_copy; + default: + return reloc_class_normal; + } +} #define TARGET_LITTLE_SYM bfd_elf32_i386_vec #define TARGET_LITTLE_NAME "elf32-i386" @@ -2246,5 +2241,6 @@ elf_i386_fake_sections (abfd, hdr, sec) #define elf_backend_relocate_section elf_i386_relocate_section #define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections #define elf_backend_fake_sections elf_i386_fake_sections +#define elf_backend_reloc_type_class elf_i386_reloc_type_class #include "elf32-target.h" |