Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: bfd/elf32-lm32.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bfd/elf32-iq2000.c ('k') | bfd/elf32-m32c.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bfd/elf32-lm32.c
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 07add20c478aa22b52983acbceada4b176e660a0..8d530a4cf31345c404391c4098d752bd8e585d94 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -1,5 +1,5 @@
/* Lattice Mico32-specific support for 32-bit ELF
- Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
Contributed by Jon Beniston <jon@beniston.com>
This file is part of BFD, the Binary File Descriptor library.
@@ -19,8 +19,8 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include "bfd.h"
#include "sysdep.h"
+#include "bfd.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/lm32.h"
@@ -217,8 +217,8 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
asection *s;
/* This function may be called more than once. */
- s = bfd_get_section_by_name (dynobj, ".got");
- if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+ s = bfd_get_linker_section (dynobj, ".got");
+ if (s != NULL)
return TRUE;
htab = lm32_elf_hash_table (info);
@@ -228,9 +228,9 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
if (! _bfd_elf_create_got_section (dynobj, info))
return FALSE;
- htab->sgot = bfd_get_section_by_name (dynobj, ".got");
- htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
- htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ htab->sgot = bfd_get_linker_section (dynobj, ".got");
+ htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+ htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
abort ();
@@ -250,16 +250,18 @@ create_rofixup_section (bfd *dynobj, struct bfd_link_info *info)
return FALSE;
/* Fixup section for R_LM32_32 relocs. */
- lm32fdpic_fixup32_section (info) = bfd_make_section_with_flags (dynobj,
- ".rofixup",
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY));
+ lm32fdpic_fixup32_section (info)
+ = bfd_make_section_anyway_with_flags (dynobj,
+ ".rofixup",
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY));
if (lm32fdpic_fixup32_section (info) == NULL
- || ! bfd_set_section_alignment (dynobj, lm32fdpic_fixup32_section (info), 2))
+ || ! bfd_set_section_alignment (dynobj,
+ lm32fdpic_fixup32_section (info), 2))
return FALSE;
return TRUE;
@@ -893,9 +895,9 @@ lm32_elf_relocate_section (bfd *output_bfd,
name = h->root.root.string;
}
- if (sec != NULL && elf_discarded_section (sec))
+ if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
- rel, relend, howto, contents);
+ rel, 1, relend, howto, 0, contents);
if (info->relocatable)
{
@@ -1031,7 +1033,8 @@ lm32_elf_relocate_section (bfd *output_bfd,
/* We need to generate a R_LM32_RELATIVE reloc
for the dynamic linker. */
- srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+ srelgot = bfd_get_linker_section (dynobj,
+ ".rela.got");
BFD_ASSERT (srelgot != NULL);
outrel.r_offset = (sgot->output_section->vma
@@ -1346,7 +1349,7 @@ lm32_elf_check_relocs (bfd *abfd,
/* Create .rofixup section */
if (htab->sfixup32 == NULL)
{
- if (! create_rofixup_section (abfd, info))
+ if (! create_rofixup_section (dynobj, info))
return FALSE;
}
break;
@@ -1356,7 +1359,9 @@ lm32_elf_check_relocs (bfd *abfd,
/* Create .rofixup section. */
if (htab->sfixup32 == NULL)
{
- if (! create_rofixup_section (abfd, info))
+ if (dynobj == NULL)
+ htab->root.dynobj = dynobj = abfd;
+ if (! create_rofixup_section (dynobj, info))
return FALSE;
}
break;
@@ -1427,7 +1432,7 @@ lm32_elf_finish_dynamic_sections (bfd *output_bfd,
dynobj = htab->root.dynobj;
sgot = htab->sgotplt;
- sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+ sdyn = bfd_get_linker_section (dynobj, ".dynamic");
if (htab->root.dynamic_sections_created)
{
@@ -1725,8 +1730,7 @@ lm32_elf_finish_dynamic_symbol (bfd *output_bfd,
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak));
- s = bfd_get_section_by_name (h->root.u.def.section->owner,
- ".rela.bss");
+ s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss");
BFD_ASSERT (s != NULL);
rela.r_offset = (h->root.u.def.value
@@ -1863,13 +1867,6 @@ lm32_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
return TRUE;
}
- if (h->size == 0)
- {
- (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
- h->root.root.string);
- return TRUE;
- }
-
/* We must allocate the symbol in our .dynbss section, which will
become part of the .bss section of the executable. There will be
an entry for this symbol in the .dynsym section. The dynamic
@@ -1891,7 +1888,7 @@ lm32_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
to copy the initial value out of the dynamic object and into the
runtime process image. We need to remember the offset into the
.rela.bss section we are going to use. */
- if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
{
asection *srel;
@@ -2146,7 +2143,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
/* Set the contents of the .interp section to the interpreter. */
if (info->executable)
{
- s = bfd_get_section_by_name (dynobj, ".interp");
+ s = bfd_get_linker_section (dynobj, ".interp");
BFD_ASSERT (s != NULL);
s->size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -2372,7 +2369,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
/* Don't generate entries for weak symbols. */
if (!h || (h && h->root.type != bfd_link_hash_undefweak))
{
- if (!elf_discarded_section (s) && !((bfd_get_section_flags (ibfd, s) & SEC_ALLOC) == 0))
+ if (!discarded_section (s) && !((bfd_get_section_flags (ibfd, s) & SEC_ALLOC) == 0))
{
switch (ELF32_R_TYPE (internal_relocs->r_info))
{
@@ -2394,7 +2391,7 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd,
if (!strcmp (current->name, h->root.root.string))
break;
}
- if (!current && !elf_discarded_section (s) && (bfd_get_section_flags (ibfd, s) & SEC_ALLOC))
+ if (!current && !discarded_section (s) && (bfd_get_section_flags (ibfd, s) & SEC_ALLOC))
{
/* Will this have an entry in the GOT. */
if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT)
@@ -2490,7 +2487,7 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
if (bed->plt_readonly)
pltflags |= SEC_READONLY;
- s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+ s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
htab->splt = s;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
@@ -2518,9 +2515,10 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
return FALSE;
}
- s = bfd_make_section_with_flags (abfd,
- bed->default_use_rela_p ? ".rela.plt" : ".rel.plt",
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd,
+ bed->default_use_rela_p
+ ? ".rela.plt" : ".rel.plt",
+ flags | SEC_READONLY);
htab->srelplt = s;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -2530,32 +2528,6 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
&& ! create_got_section (abfd, info))
return FALSE;
- {
- const char *secname;
- char *relname;
- flagword secflags;
- asection *sec;
-
- for (sec = abfd->sections; sec; sec = sec->next)
- {
- secflags = bfd_get_section_flags (abfd, sec);
- if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
- || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
- continue;
- secname = bfd_get_section_name (abfd, sec);
- relname = bfd_malloc ((bfd_size_type) strlen (secname) + 6);
- strcpy (relname, ".rela");
- strcat (relname, secname);
- if (bfd_get_section_by_name (abfd, secname))
- continue;
- s = bfd_make_section_with_flags (abfd, relname,
- flags | SEC_READONLY);
- if (s == NULL
- || ! bfd_set_section_alignment (abfd, s, ptralign))
- return FALSE;
- }
- }
-
if (bed->want_dynbss)
{
/* The .dynbss section is a place to put symbols which are defined
@@ -2564,8 +2536,8 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
image and use a R_*_COPY reloc to tell the dynamic linker to
initialize them at run time. The linker script puts the .dynbss
section into the .bss section of the final image. */
- s = bfd_make_section_with_flags (abfd, ".dynbss",
- SEC_ALLOC | SEC_LINKER_CREATED);
+ s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+ SEC_ALLOC | SEC_LINKER_CREATED);
htab->sdynbss = s;
if (s == NULL)
return FALSE;
@@ -2582,10 +2554,10 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
copy relocs. */
if (! info->shared)
{
- s = bfd_make_section_with_flags (abfd,
- (bed->default_use_rela_p
- ? ".rela.bss" : ".rel.bss"),
- flags | SEC_READONLY);
+ s = bfd_make_section_anyway_with_flags (abfd,
+ (bed->default_use_rela_p
+ ? ".rela.bss" : ".rel.bss"),
+ flags | SEC_READONLY);
htab->srelbss = s;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, ptralign))
« no previous file with comments | « bfd/elf32-iq2000.c ('k') | bfd/elf32-m32c.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698