projects
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add --no-dynamic-linker option to ld, for static PIE use
[binutils-gdb.git]
/
bfd
/
elf32-i370.c
diff --git
a/bfd/elf32-i370.c
b/bfd/elf32-i370.c
index c9f4333bba41fb0256b36cc7ea9e56606139079b..458f69495d066f901259fd8c8b47035adc18f1c5 100644
(file)
--- a/
bfd/elf32-i370.c
+++ b/
bfd/elf32-i370.c
@@
-1,6
+1,5
@@
/* i370-specific support for 32-bit ELF
/* i370-specific support for 32-bit ELF
- Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1994-2015 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
Hacked by Linas Vepstas for i370 linas@linas.org
Written by Ian Lance Taylor, Cygnus Support.
Hacked by Linas Vepstas for i370 linas@linas.org
@@
-41,11
+40,11
@@
static reloc_howto_type i370_elf_howto_raw[] =
/* This reloc does nothing. */
HOWTO (R_I370_NONE, /* type */
0, /* rightshift */
/* This reloc does nothing. */
HOWTO (R_I370_NONE, /* type */
0, /* rightshift */
-
2
, /* size (0 = byte, 1 = short, 2 = long) */
-
32,
/* bitsize */
+
3
, /* size (0 = byte, 1 = short, 2 = long) */
+
0,
/* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
FALSE, /* pc_relative */
0, /* bitpos */
- complain_overflow_
bitfield
, /* complain_on_overflow */
+ complain_overflow_
dont
, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_I370_NONE", /* name */
FALSE, /* partial_inplace */
bfd_elf_generic_reloc, /* special_function */
"R_I370_NONE", /* name */
FALSE, /* partial_inplace */
@@
-295,12
+294,21
@@
i370_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
arelent *cache_ptr,
Elf_Internal_Rela *dst)
{
arelent *cache_ptr,
Elf_Internal_Rela *dst)
{
+ unsigned int r_type;
+
if (!i370_elf_howto_table[ R_I370_ADDR31 ])
/* Initialize howto table. */
i370_elf_howto_init ();
if (!i370_elf_howto_table[ R_I370_ADDR31 ])
/* Initialize howto table. */
i370_elf_howto_init ();
- BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_I370_max);
- cache_ptr->howto = i370_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
+ r_type = ELF32_R_TYPE (dst->r_info);
+ if (r_type >= R_I370_max)
+ {
+ (*_bfd_error_handler) (_("%B: unrecognised I370 reloc number: %d"),
+ abfd, r_type);
+ bfd_set_error (bfd_error_bad_value);
+ r_type = R_I370_NONE;
+ }
+ cache_ptr->howto = i370_elf_howto_table[r_type];
}
/* Hack alert -- the following several routines look generic to me ...
}
/* Hack alert -- the following several routines look generic to me ...
@@
-420,23
+428,23
@@
i370_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
| SEC_LINKER_CREATED);
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
| SEC_LINKER_CREATED);
- s = bfd_make_section_with_flags (abfd, ".dynsbss",
- SEC_ALLOC | SEC_LINKER_CREATED);
+ s = bfd_make_section_
anyway_
with_flags (abfd, ".dynsbss",
+
SEC_ALLOC | SEC_LINKER_CREATED);
if (s == NULL)
return FALSE;
if (s == NULL)
return FALSE;
- if (!
info->shared
)
+ if (!
bfd_link_pic (info)
)
{
{
- s = bfd_make_section_with_flags (abfd, ".rela.sbss",
- flags | SEC_READONLY);
+ s = bfd_make_section_
anyway_
with_flags (abfd, ".rela.sbss",
+
flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
return FALSE;
}
/* XXX beats me, seem to need a rela.text ... */
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
return FALSE;
}
/* XXX beats me, seem to need a rela.text ... */
- s = bfd_make_section_with_flags (abfd, ".rela.text",
- flags | SEC_READONLY);
+ s = bfd_make_section_
anyway_
with_flags (abfd, ".rela.text",
+
flags | SEC_READONLY);
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
return FALSE;
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, 2))
return FALSE;
@@
-472,7
+480,7
@@
i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
&& h->ref_regular
&& !h->def_regular)));
&& h->ref_regular
&& !h->def_regular)));
- s = bfd_get_
section_by_name
(dynobj, ".rela.text");
+ s = bfd_get_
linker_section
(dynobj, ".rela.text");
BFD_ASSERT (s != NULL);
s->size += sizeof (Elf32_External_Rela);
BFD_ASSERT (s != NULL);
s->size += sizeof (Elf32_External_Rela);
@@
-495,16
+503,9
@@
i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
only references to the symbol are via the global offset table.
For such cases we need not do anything here; the relocations will
be handled correctly by relocate_section. */
only references to the symbol are via the global offset table.
For such cases we need not do anything here; the relocations will
be handled correctly by relocate_section. */
- if (
info->shared
)
+ if (
bfd_link_pic (info)
)
return TRUE;
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
/* 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
@@
-520,29
+521,29
@@
i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
only if there were actually SDAREL relocs for that symbol. */
if (h->size <= elf_gp_size (dynobj))
only if there were actually SDAREL relocs for that symbol. */
if (h->size <= elf_gp_size (dynobj))
- s = bfd_get_
section_by_name
(dynobj, ".dynsbss");
+ s = bfd_get_
linker_section
(dynobj, ".dynsbss");
else
else
- s = bfd_get_
section_by_name
(dynobj, ".dynbss");
+ s = bfd_get_
linker_section
(dynobj, ".dynbss");
BFD_ASSERT (s != NULL);
/* We must generate a R_I370_COPY reloc to tell the dynamic linker 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. */
BFD_ASSERT (s != NULL);
/* We must generate a R_I370_COPY reloc to tell the dynamic linker 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;
if (h->size <= elf_gp_size (dynobj))
{
asection *srel;
if (h->size <= elf_gp_size (dynobj))
- srel = bfd_get_
section_by_name
(dynobj, ".rela.sbss");
+ srel = bfd_get_
linker_section
(dynobj, ".rela.sbss");
else
else
- srel = bfd_get_
section_by_name
(dynobj, ".rela.bss");
+ srel = bfd_get_
linker_section
(dynobj, ".rela.bss");
BFD_ASSERT (srel != NULL);
srel->size += sizeof (Elf32_External_Rela);
h->needs_copy = 1;
}
BFD_ASSERT (srel != NULL);
srel->size += sizeof (Elf32_External_Rela);
h->needs_copy = 1;
}
- return _bfd_elf_adjust_dynamic_copy (h, s);
+ return _bfd_elf_adjust_dynamic_copy (
info,
h, s);
}
\f
/* Increment the index of a dynamic symbol by a given amount. Called
}
\f
/* Increment the index of a dynamic symbol by a given amount. Called
@@
-593,9
+594,9
@@
i370_elf_size_dynamic_sections (bfd *output_bfd,
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (
info->executable
)
+ if (
bfd_link_executable (info) && !info->nointerp
)
{
{
- 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;
BFD_ASSERT (s != NULL);
s->size = sizeof ELF_DYNAMIC_INTERPRETER;
s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@
-615,7
+616,7
@@
i370_elf_size_dynamic_sections (bfd *output_bfd,
for (p = rela_sections; *p != NULL; p++)
{
for (p = rela_sections; *p != NULL; p++)
{
- s = bfd_get_
section_by_name
(dynobj, *p);
+ s = bfd_get_
linker_section
(dynobj, *p);
if (s != NULL)
s->size = 0;
}
if (s != NULL)
s->size = 0;
}
@@
-712,7
+713,7
@@
i370_elf_size_dynamic_sections (bfd *output_bfd,
#define add_dynamic_entry(TAG, VAL) \
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
#define add_dynamic_entry(TAG, VAL) \
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
- if (!
info->shared
)
+ if (!
bfd_link_pic (info)
)
{
if (!add_dynamic_entry (DT_DEBUG, 0))
return FALSE;
{
if (!add_dynamic_entry (DT_DEBUG, 0))
return FALSE;
@@
-754,7
+755,7
@@
i370_elf_size_dynamic_sections (bfd *output_bfd,
locations in linker-created sections that do not have
externally-visible names. Instead, we should work out precisely
which sections relocations are targeted at. */
locations in linker-created sections that do not have
externally-visible names. Instead, we should work out precisely
which sections relocations are targeted at. */
- if (
info->shared
)
+ if (
bfd_link_pic (info)
)
{
int c;
{
int c;
@@
-803,7
+804,7
@@
i370_elf_check_relocs (bfd *abfd,
const Elf_Internal_Rela *rel_end;
asection *sreloc;
const Elf_Internal_Rela *rel_end;
asection *sreloc;
- if (
info->relocatable
)
+ if (
bfd_link_relocatable (info)
)
return TRUE;
#ifdef DEBUG
return TRUE;
#ifdef DEBUG
@@
-832,9
+833,13
@@
i370_elf_check_relocs (bfd *abfd,
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ /* PR15323, ref flags aren't set for references in the same
+ object. */
+ h->root.non_ir_ref = 1;
}
}
- if (
info->shared
)
+ if (
bfd_link_pic (info)
)
{
#ifdef DEBUG
fprintf (stderr,
{
#ifdef DEBUG
fprintf (stderr,
@@
-876,20
+881,20
@@
i370_elf_finish_dynamic_sections (bfd *output_bfd,
{
asection *sdyn;
bfd *dynobj = elf_hash_table (info)->dynobj;
{
asection *sdyn;
bfd *dynobj = elf_hash_table (info)->dynobj;
- asection *sgot = bfd_get_
section_by_name
(dynobj, ".got");
+ asection *sgot = bfd_get_
linker_section
(dynobj, ".got");
#ifdef DEBUG
fprintf (stderr, "i370_elf_finish_dynamic_sections called\n");
#endif
#ifdef DEBUG
fprintf (stderr, "i370_elf_finish_dynamic_sections called\n");
#endif
- sdyn = bfd_get_
section_by_name
(dynobj, ".dynamic");
+ sdyn = bfd_get_
linker_section
(dynobj, ".dynamic");
if (elf_hash_table (info)->dynamic_sections_created)
{
asection *splt;
Elf32_External_Dyn *dyncon, *dynconend;
if (elf_hash_table (info)->dynamic_sections_created)
{
asection *splt;
Elf32_External_Dyn *dyncon, *dynconend;
- splt = bfd_get_
section_by_name
(dynobj, ".plt");
+ splt = bfd_get_
linker_section
(dynobj, ".plt");
BFD_ASSERT (splt != NULL && sdyn != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
BFD_ASSERT (splt != NULL && sdyn != NULL);
dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@
-943,7
+948,7
@@
i370_elf_finish_dynamic_sections (bfd *output_bfd,
elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
}
elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
}
- if (
info->shared
)
+ if (
bfd_link_pic (info)
)
{
asection *sdynsym;
asection *s;
{
asection *sdynsym;
asection *s;
@@
-952,7
+957,7
@@
i370_elf_finish_dynamic_sections (bfd *output_bfd,
/* Set up the section symbols for the output sections. */
/* Set up the section symbols for the output sections. */
- sdynsym = bfd_get_
section_by_name
(dynobj, ".dynsym");
+ sdynsym = bfd_get_
linker_section
(dynobj, ".dynsym");
BFD_ASSERT (sdynsym != NULL);
sym.st_size = 0;
BFD_ASSERT (sdynsym != NULL);
sym.st_size = 0;
@@
-1044,7
+1049,7
@@
i370_elf_relocate_section (bfd *output_bfd,
_bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %ld relocations%s",
input_bfd, input_section,
(long) input_section->reloc_count,
_bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %ld relocations%s",
input_bfd, input_section,
(long) input_section->reloc_count,
- (
info->relocatable
) ? " (relocatable)" : "");
+ (
bfd_link_relocatable (info)
) ? " (relocatable)" : "");
#endif
if (!i370_elf_howto_table[ R_I370_ADDR31 ])
#endif
if (!i370_elf_howto_table[ R_I370_ADDR31 ])
@@
-1094,6
+1099,12
@@
i370_elf_relocate_section (bfd *output_bfd,
else
{
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
else
{
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+ if (info->wrap_hash != NULL
+ && (input_section->flags & SEC_DEBUGGING) != 0)
+ h = ((struct elf_link_hash_entry *)
+ unwrap_hash_lookup (info, input_bfd, &h->root));
+
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
@@
-1102,7
+1113,7
@@
i370_elf_relocate_section (bfd *output_bfd,
|| h->root.type == bfd_link_hash_defweak)
{
sec = h->root.u.def.section;
|| h->root.type == bfd_link_hash_defweak)
{
sec = h->root.u.def.section;
- if (
info->shared
+ if (
bfd_link_pic (info)
&& ((! info->symbolic && h->dynindx != -1)
|| !h->def_regular)
&& (input_section->flags & SEC_ALLOC) != 0
&& ((! info->symbolic && h->dynindx != -1)
|| !h->def_regular)
&& (input_section->flags & SEC_ALLOC) != 0
@@
-1124,7
+1135,7
@@
i370_elf_relocate_section (bfd *output_bfd,
else if (info->unresolved_syms_in_objects == RM_IGNORE
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
else if (info->unresolved_syms_in_objects == RM_IGNORE
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
;
- else if (!
info->relocatable
)
+ else if (!
bfd_link_relocatable (info)
)
{
if ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd,
{
if ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd,
@@
-1138,11
+1149,11
@@
i370_elf_relocate_section (bfd *output_bfd,
}
}
}
}
- if (sec != NULL &&
elf_
discarded_section (sec))
+ if (sec != NULL && discarded_section (sec))
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
- rel,
relend, howto
, contents);
+ rel,
1, relend, howto, 0
, contents);
- if (
info->relocatable
)
+ if (
bfd_link_relocatable (info)
)
continue;
switch ((int) r_type)
continue;
switch ((int) r_type)
@@
-1173,7
+1184,7
@@
i370_elf_relocate_section (bfd *output_bfd,
object. */
case (int) R_I370_ADDR31:
case (int) R_I370_ADDR16:
object. */
case (int) R_I370_ADDR31:
case (int) R_I370_ADDR16:
- if (
info->shared
+ if (
bfd_link_pic (info)
&& r_symndx != STN_UNDEF)
{
Elf_Internal_Rela outrel;
&& r_symndx != STN_UNDEF)
{
Elf_Internal_Rela outrel;
@@
-1360,7
+1371,7
@@
i370_elf_relocate_section (bfd *output_bfd,
return ret;
}
\f
return ret;
}
\f
-#define TARGET_BIG_SYM
bfd_elf32_i370
_vec
+#define TARGET_BIG_SYM
i370_elf32
_vec
#define TARGET_BIG_NAME "elf32-i370"
#define ELF_ARCH bfd_arch_i370
#define ELF_MACHINE_CODE EM_S370
#define TARGET_BIG_NAME "elf32-i370"
#define ELF_ARCH bfd_arch_i370
#define ELF_MACHINE_CODE EM_S370
@@
-1368,7
+1379,7
@@
i370_elf_relocate_section (bfd *output_bfd,
#define ELF_MACHINE_ALT1 EM_I370_OLD
#endif
#define ELF_MAXPAGESIZE 0x1000
#define ELF_MACHINE_ALT1 EM_I370_OLD
#endif
#define ELF_MAXPAGESIZE 0x1000
-#define ELF_OSABI ELFOSABI_
LINUX
+#define ELF_OSABI ELFOSABI_
GNU
#define elf_info_to_howto i370_elf_info_to_howto
#define elf_info_to_howto i370_elf_info_to_howto
@@
-1391,7
+1402,6
@@
i370_elf_relocate_section (bfd *output_bfd,
#define elf_backend_section_from_shdr i370_elf_section_from_shdr
#define elf_backend_adjust_dynamic_symbol i370_elf_adjust_dynamic_symbol
#define elf_backend_check_relocs i370_elf_check_relocs
#define elf_backend_section_from_shdr i370_elf_section_from_shdr
#define elf_backend_adjust_dynamic_symbol i370_elf_adjust_dynamic_symbol
#define elf_backend_check_relocs i370_elf_check_relocs
-#define elf_backend_post_process_headers _bfd_elf_set_osabi
static int
i370_noop (void)
static int
i370_noop (void)