X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fsunos.c;h=028fb280e3b12a55a77245b74f1f8ed15d63e2aa;hb=95830fd17d6ae253d8f6c2595188cadd59058799;hp=1c17dce275a97cf2b0902d4f59c20b8860a6e134;hpb=cd123cb70c845b890eed231a84e6e84c92c2ef92;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/sunos.c b/bfd/sunos.c index 1c17dce275..028fb280e3 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -1,6 +1,7 @@ /* BFD backend for SunOS binaries. Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -27,6 +28,7 @@ the tokens. */ #define MY(OP) CONCAT2 (sunos_big_,OP) +#include "sysdep.h" #include "bfd.h" #include "bfdlink.h" #include "libaout.h" @@ -746,49 +748,53 @@ sunos_create_dynamic_sections (bfd *abfd, /* The .dynamic section holds the basic dynamic information: the sun4_dynamic structure, the dynamic debugger information, and the sun4_dynamic_link structure. */ - s = bfd_make_section_with_flags (abfd, ".dynamic", flags); + s = bfd_make_section_anyway_with_flags (abfd, ".dynamic", flags); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; /* The .got section holds the global offset table. The address is put in the ld_got field. */ - s = bfd_make_section_with_flags (abfd, ".got", flags); + s = bfd_make_section_anyway_with_flags (abfd, ".got", flags); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; /* The .plt section holds the procedure linkage table. The address is put in the ld_plt field. */ - s = bfd_make_section_with_flags (abfd, ".plt", flags | SEC_CODE); + s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_CODE); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; /* The .dynrel section holds the dynamic relocs. The address is put in the ld_rel field. */ - s = bfd_make_section_with_flags (abfd, ".dynrel", flags | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, ".dynrel", + flags | SEC_READONLY); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; /* The .hash section holds the dynamic hash table. The address is put in the ld_hash field. */ - s = bfd_make_section_with_flags (abfd, ".hash", flags | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, ".hash", + flags | SEC_READONLY); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; /* The .dynsym section holds the dynamic symbols. The address is put in the ld_stab field. */ - s = bfd_make_section_with_flags (abfd, ".dynsym", flags | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, ".dynsym", + flags | SEC_READONLY); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; /* The .dynstr section holds the dynamic symbol string table. The address is put in the ld_symbols field. */ - s = bfd_make_section_with_flags (abfd, ".dynstr", flags | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, ".dynstr", + flags | SEC_READONLY); if (s == NULL || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; @@ -803,7 +809,7 @@ sunos_create_dynamic_sections (bfd *abfd, dynobj = sunos_hash_table (info)->dynobj; - s = bfd_get_section_by_name (dynobj, ".got"); + s = bfd_get_linker_section (dynobj, ".got"); if (s->size == 0) s->size = BYTES_IN_WORD; @@ -829,7 +835,7 @@ sunos_add_dynamic_symbols (bfd *abfd, unsigned long need; /* Make sure we have all the required sections. */ - if (info->hash->creator == abfd->xvec) + if (info->output_bfd->xvec == abfd->xvec) { if (! sunos_create_dynamic_sections (abfd, info, ((abfd->flags & DYNAMIC) != 0 @@ -870,7 +876,7 @@ sunos_add_dynamic_symbols (bfd *abfd, /* There's no hope of using a dynamic object which does not exactly match the format of the output file. */ - if (info->hash->creator != abfd->xvec) + if (info->output_bfd->xvec != abfd->xvec) { bfd_set_error (bfd_error_invalid_operation); return FALSE; @@ -1121,7 +1127,7 @@ sunos_add_one_symbol (struct bfd_link_info *info, } if ((abfd->flags & DYNAMIC) != 0 - && abfd->xvec == info->hash->creator + && abfd->xvec == info->output_bfd->xvec && (h->flags & SUNOS_CONSTRUCTOR) != 0) /* The existing symbol is a constructor symbol, and this symbol is from a dynamic object. A constructor symbol is actually a @@ -1145,7 +1151,7 @@ sunos_add_one_symbol (struct bfd_link_info *info, hashp)) return FALSE; - if (abfd->xvec == info->hash->creator) + if (abfd->xvec == info->output_bfd->xvec) { /* Set a flag in the hash table entry indicating the type of reference or definition we just found. Keep a count of the @@ -1191,7 +1197,7 @@ struct bfd_link_needed_list * bfd_sunos_get_needed_list (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { - if (info->hash->creator != &MY (vec)) + if (info->output_bfd->xvec != &MY (vec)) return NULL; return sunos_hash_table (info)->needed; } @@ -1323,11 +1329,11 @@ sunos_scan_std_relocs (struct bfd_link_info *info, if (! sunos_create_dynamic_sections (abfd, info, FALSE)) return FALSE; dynobj = sunos_hash_table (info)->dynobj; - splt = bfd_get_section_by_name (dynobj, ".plt"); - srel = bfd_get_section_by_name (dynobj, ".dynrel"); + splt = bfd_get_linker_section (dynobj, ".plt"); + srel = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (splt != NULL && srel != NULL); - sgot = bfd_get_section_by_name (dynobj, ".got"); + sgot = bfd_get_linker_section (dynobj, ".got"); BFD_ASSERT (sgot != NULL); if (sgot->size == 0) sgot->size = BYTES_IN_WORD; @@ -1473,9 +1479,9 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, if (! sunos_create_dynamic_sections (abfd, info, FALSE)) return FALSE; dynobj = sunos_hash_table (info)->dynobj; - splt = bfd_get_section_by_name (dynobj, ".plt"); - sgot = bfd_get_section_by_name (dynobj, ".got"); - srel = bfd_get_section_by_name (dynobj, ".dynrel"); + splt = bfd_get_linker_section (dynobj, ".plt"); + sgot = bfd_get_linker_section (dynobj, ".got"); + srel = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL); /* Make sure we have an initial entry in the .got table. */ @@ -1541,9 +1547,9 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, if (! sunos_create_dynamic_sections (abfd, info, TRUE)) return FALSE; dynobj = sunos_hash_table (info)->dynobj; - splt = bfd_get_section_by_name (dynobj, ".plt"); - sgot = bfd_get_section_by_name (dynobj, ".got"); - srel = bfd_get_section_by_name (dynobj, ".dynrel"); + splt = bfd_get_linker_section (dynobj, ".plt"); + sgot = bfd_get_linker_section (dynobj, ".got"); + srel = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL); } @@ -1588,9 +1594,9 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, if (! sunos_create_dynamic_sections (abfd, info, FALSE)) return FALSE; dynobj = sunos_hash_table (info)->dynobj; - splt = bfd_get_section_by_name (dynobj, ".plt"); - sgot = bfd_get_section_by_name (dynobj, ".got"); - srel = bfd_get_section_by_name (dynobj, ".dynrel"); + splt = bfd_get_linker_section (dynobj, ".plt"); + sgot = bfd_get_linker_section (dynobj, ".got"); + srel = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL); /* Make sure we have an initial entry in the .got table. */ @@ -1748,9 +1754,6 @@ sunos_scan_dynamic_symbol (struct sunos_link_hash_entry *h, void * data) { struct bfd_link_info *info = (struct bfd_link_info *) data; - if (h->root.root.type == bfd_link_hash_warning) - h = (struct sunos_link_hash_entry *) h->root.root.u.i.link; - /* Set the written flag for symbols we do not want to write out as part of the regular symbol table. This is all symbols which are not defined in a regular object file. For some reason symbols @@ -1816,7 +1819,7 @@ sunos_scan_dynamic_symbol (struct sunos_link_hash_entry *h, void * data) regular symbols includes the debugging symbols, which have long names and are often duplicated in several object files. There are no debugging symbols in the dynamic symbols. */ - s = bfd_get_section_by_name (dynobj, ".dynstr"); + s = bfd_get_linker_section (dynobj, ".dynstr"); BFD_ASSERT (s != NULL); contents = bfd_realloc (s->contents, s->size + len + 1); if (contents == NULL) @@ -1835,7 +1838,7 @@ sunos_scan_dynamic_symbol (struct sunos_link_hash_entry *h, void * data) hash &= 0x7fffffff; hash %= sunos_hash_table (info)->bucketcount; - s = bfd_get_section_by_name (dynobj, ".hash"); + s = bfd_get_linker_section (dynobj, ".hash"); BFD_ASSERT (s != NULL); if (GET_SWORD (dynobj, s->contents + hash * HASH_ENTRY_SIZE) == -1) @@ -1932,14 +1935,14 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, ++sunos_hash_table (info)->dynsymcount; h->dynindx = -2; } + s = bfd_get_linker_section (dynobj, ".got"); + BFD_ASSERT (s != NULL); h->root.root.type = bfd_link_hash_defined; - h->root.root.u.def.section = bfd_get_section_by_name (dynobj, ".got"); + h->root.root.u.def.section = s; /* If the .got section is more than 0x1000 bytes, we set __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section, so that 13 bit relocations have a greater chance of working. */ - s = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (s != NULL); if (s->size >= 0x1000) h->root.root.u.def.value = 0x1000; else @@ -1952,7 +1955,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, up the dynamic linking information. */ if (sunos_hash_table (info)->dynamic_sections_needed) { - *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic"); + *sdynptr = bfd_get_linker_section (dynobj, ".dynamic"); /* The .dynamic section is always the same size. */ s = *sdynptr; @@ -1969,7 +1972,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, symbols. We build the dynamic symbol string table (.dynstr) in a traversal of the symbol table using sunos_scan_dynamic_symbol. */ - s = bfd_get_section_by_name (dynobj, ".dynsym"); + s = bfd_get_linker_section (dynobj, ".dynsym"); BFD_ASSERT (s != NULL); s->size = dynsymcount * sizeof (struct external_nlist); s->contents = bfd_alloc (output_bfd, s->size); @@ -1990,7 +1993,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, bucketcount = dynsymcount; else bucketcount = 1; - s = bfd_get_section_by_name (dynobj, ".hash"); + s = bfd_get_linker_section (dynobj, ".hash"); BFD_ASSERT (s != NULL); hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE; s->contents = bfd_zalloc (dynobj, hashalloc); @@ -2014,7 +2017,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, /* The SunOS native linker seems to align the total size of the symbol strings to a multiple of 8. I don't know if this is important, but it can't hurt much. */ - s = bfd_get_section_by_name (dynobj, ".dynstr"); + s = bfd_get_linker_section (dynobj, ".dynstr"); BFD_ASSERT (s != NULL); if ((s->size & 7) != 0) { @@ -2033,7 +2036,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, /* Now that we have worked out the sizes of the procedure linkage table and the dynamic relocs, allocate storage for them. */ - s = bfd_get_section_by_name (dynobj, ".plt"); + s = bfd_get_linker_section (dynobj, ".plt"); BFD_ASSERT (s != NULL); if (s->size != 0) { @@ -2057,7 +2060,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, } } - s = bfd_get_section_by_name (dynobj, ".dynrel"); + s = bfd_get_linker_section (dynobj, ".dynrel"); if (s->size != 0) { s->contents = bfd_alloc (dynobj, s->size); @@ -2069,7 +2072,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, s->reloc_count = 0; /* Make space for the global offset table. */ - s = bfd_get_section_by_name (dynobj, ".got"); + s = bfd_get_linker_section (dynobj, ".got"); s->contents = bfd_alloc (dynobj, s->size); if (s->contents == NULL) return FALSE; @@ -2115,10 +2118,10 @@ sunos_write_dynamic_symbol (bfd *output_bfd, bfd_vma r_address; dynobj = sunos_hash_table (info)->dynobj; - splt = bfd_get_section_by_name (dynobj, ".plt"); + splt = bfd_get_linker_section (dynobj, ".plt"); p = splt->contents + h->plt_offset; - s = bfd_get_section_by_name (dynobj, ".dynrel"); + s = bfd_get_linker_section (dynobj, ".dynrel"); r_address = (splt->output_section->vma + splt->output_offset @@ -2302,7 +2305,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd, return TRUE; } - s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym"); + s = bfd_get_linker_section (sunos_hash_table (info)->dynobj, ".dynsym"); BFD_ASSERT (s != NULL); outsym = ((struct external_nlist *) (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE)); @@ -2357,7 +2360,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, asection *splt; /* Redirect the relocation to the PLT entry. */ - splt = bfd_get_section_by_name (dynobj, ".plt"); + splt = bfd_get_linker_section (dynobj, ".plt"); *relocationp = (splt->output_section->vma + splt->output_offset + h->plt_offset); @@ -2452,7 +2455,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, BFD_ASSERT (got_offsetp != NULL && *got_offsetp != 0); - sgot = bfd_get_section_by_name (dynobj, ".got"); + sgot = bfd_get_linker_section (dynobj, ".got"); /* We set the least significant bit to indicate whether we have already initialized the GOT entry. */ @@ -2474,7 +2477,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, /* We need to create a GLOB_DAT or 32 reloc to tell the dynamic linker to fill in this entry in the table. */ - s = bfd_get_section_by_name (dynobj, ".dynrel"); + s = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (s != NULL); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->size); @@ -2604,7 +2607,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, /* It looks like this is a reloc we are supposed to copy. */ - s = bfd_get_section_by_name (dynobj, ".dynrel"); + s = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (s != NULL); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->size); @@ -2702,7 +2705,7 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info) dynobj = sunos_hash_table (info)->dynobj; - sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + sdyn = bfd_get_linker_section (dynobj, ".dynamic"); BFD_ASSERT (sdyn != NULL); /* Finish up the .need section. The linker emulation code filled it @@ -2732,7 +2735,7 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info) /* The first entry in the .got section is the address of the dynamic information, unless this is a shared library. */ - s = bfd_get_section_by_name (dynobj, ".got"); + s = bfd_get_linker_section (dynobj, ".got"); BFD_ASSERT (s != NULL); if (info->shared || sdyn->size == 0) PUT_WORD (dynobj, 0, s->contents); @@ -2794,30 +2797,30 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info) PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_rules); - s = bfd_get_section_by_name (dynobj, ".got"); + s = bfd_get_linker_section (dynobj, ".got"); BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->vma + s->output_offset, esdl.ld_got); - s = bfd_get_section_by_name (dynobj, ".plt"); + s = bfd_get_linker_section (dynobj, ".plt"); BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->vma + s->output_offset, esdl.ld_plt); PUT_WORD (dynobj, s->size, esdl.ld_plt_sz); - s = bfd_get_section_by_name (dynobj, ".dynrel"); + s = bfd_get_linker_section (dynobj, ".dynrel"); BFD_ASSERT (s != NULL); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) == s->size); PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_rel); - s = bfd_get_section_by_name (dynobj, ".hash"); + s = bfd_get_linker_section (dynobj, ".hash"); BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_hash); - s = bfd_get_section_by_name (dynobj, ".dynsym"); + s = bfd_get_linker_section (dynobj, ".dynsym"); BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_stab); @@ -2827,7 +2830,7 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info) PUT_WORD (dynobj, (bfd_vma) sunos_hash_table (info)->bucketcount, esdl.ld_buckets); - s = bfd_get_section_by_name (dynobj, ".dynstr"); + s = bfd_get_linker_section (dynobj, ".dynstr"); BFD_ASSERT (s != NULL); PUT_WORD (dynobj, s->output_section->filepos + s->output_offset, esdl.ld_symbols);