* elf-bfd.h (_bfd_elf_define_linkage_sym): Declare.
* elflink.c (_bfd_elf_define_linkage_sym): New function, extracted from.. (_bfd_elf_create_got_section): ..here. (_bfd_elf_link_create_dynamic_sections): Call it for _DYNAMIC. (_bfd_elf_create_dynamic_sections): ..and _PROCEDURE_LINKAGE_TABLE_. * elf-m10300.c (_bfd_mn10300_elf_create_got_section): Use _bfd_elf_define_linkage_sym. * elf32-frv.c (_frv_create_got_section): Likewise. * elf64-alpha.c (elf64_alpha_create_dynamic_sections): Likewise.
This commit is contained in:
parent
36ae0db314
commit
d98685ac81
@ -1,3 +1,16 @@
|
||||
2005-08-16 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf-bfd.h (_bfd_elf_define_linkage_sym): Declare.
|
||||
* elflink.c (_bfd_elf_define_linkage_sym): New function, extracted
|
||||
from..
|
||||
(_bfd_elf_create_got_section): ..here.
|
||||
(_bfd_elf_link_create_dynamic_sections): Call it for _DYNAMIC.
|
||||
(_bfd_elf_create_dynamic_sections): ..and _PROCEDURE_LINKAGE_TABLE_.
|
||||
* elf-m10300.c (_bfd_mn10300_elf_create_got_section): Use
|
||||
_bfd_elf_define_linkage_sym.
|
||||
* elf32-frv.c (_frv_create_got_section): Likewise.
|
||||
* elf64-alpha.c (elf64_alpha_create_dynamic_sections): Likewise.
|
||||
|
||||
2005-08-15 Paul Brook <paul@codesourcery.com>
|
||||
|
||||
* elf32-arm.c (elf32_arm_howto_table_1): Make R_ARM_PLT32 the same as
|
||||
|
@ -1639,6 +1639,8 @@ extern bfd_boolean _bfd_elf_create_dynamic_sections
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern bfd_boolean _bfd_elf_create_got_section
|
||||
(bfd *, struct bfd_link_info *);
|
||||
extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
|
||||
(bfd *, struct bfd_link_info *, asection *, const char *);
|
||||
|
||||
extern bfd_boolean _bfd_elfcore_make_pseudosection
|
||||
(bfd *, char *, size_t, ufile_ptr);
|
||||
|
@ -542,7 +542,6 @@ _bfd_mn10300_elf_create_got_section (abfd, info)
|
||||
flagword flags;
|
||||
flagword pltflags;
|
||||
asection * s;
|
||||
struct bfd_link_hash_entry * bh;
|
||||
struct elf_link_hash_entry * h;
|
||||
const struct elf_backend_data * bed = get_elf_backend_data (abfd);
|
||||
int ptralign;
|
||||
@ -581,24 +580,12 @@ _bfd_mn10300_elf_create_got_section (abfd, info)
|
||||
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
|
||||
return FALSE;
|
||||
|
||||
if (bed->want_plt_sym)
|
||||
{
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
bh = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
|
||||
(bfd_vma) 0, (const char *) NULL, FALSE,
|
||||
get_elf_backend_data (abfd)->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
}
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
if (bed->want_plt_sym
|
||||
&& !_bfd_elf_define_linkage_sym (abfd, info, s,
|
||||
"_PROCEDURE_LINKAGE_TABLE_"))
|
||||
return FALSE;
|
||||
|
||||
s = bfd_make_section_with_flags (abfd, ".got", flags);
|
||||
if (s == NULL
|
||||
@ -617,20 +604,10 @@ _bfd_mn10300_elf_create_got_section (abfd, info)
|
||||
(or .got.plt) section. We don't do this in the linker script
|
||||
because we don't want to define the symbol if we are not creating
|
||||
a global offset table. */
|
||||
bh = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
|
||||
0, (const char *) NULL, FALSE, bed->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
|
||||
h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
|
||||
elf_hash_table (info)->hgot = h;
|
||||
if (h == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* The first bit of the global offset table is the header. */
|
||||
s->size += bed->got_header_size;
|
||||
|
@ -4301,22 +4301,15 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
|
||||
(or .got.plt) section. We don't do this in the linker script
|
||||
because we don't want to define the symbol if we are not creating
|
||||
a global offset table. */
|
||||
bh = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
|
||||
0, (const char *) NULL, FALSE, bed->collect, &bh)))
|
||||
h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
|
||||
elf_hash_table (info)->hgot = h;
|
||||
if (h == NULL)
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
/* h->other = STV_HIDDEN; */ /* Should we? */
|
||||
|
||||
/* Machine-specific: we want the symbol for executables as
|
||||
well. */
|
||||
if (! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
|
||||
elf_hash_table (info)->hgot = h;
|
||||
}
|
||||
|
||||
/* The first bit of the global offset table is the header. */
|
||||
@ -4399,26 +4392,12 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info)
|
||||
/* FRV-specific: remember it. */
|
||||
frvfdpic_plt_section (info) = s;
|
||||
|
||||
if (bed->want_plt_sym)
|
||||
{
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
struct elf_link_hash_entry *h;
|
||||
struct bfd_link_hash_entry *bh = NULL;
|
||||
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 0, NULL,
|
||||
FALSE, get_elf_backend_data (abfd)->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
/* h->other = STV_HIDDEN; */ /* Should we? */
|
||||
|
||||
if (! info->executable
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
}
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
if (bed->want_plt_sym
|
||||
&& !_bfd_elf_define_linkage_sym (abfd, info, s,
|
||||
"_PROCEDURE_LINKAGE_TABLE_"))
|
||||
return FALSE;
|
||||
|
||||
/* FRV-specific: we want rel relocations for the plt. */
|
||||
s = bfd_make_section_with_flags (abfd, ".rel.plt",
|
||||
|
@ -1232,7 +1232,6 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
asection *s;
|
||||
flagword flags;
|
||||
struct elf_link_hash_entry *h;
|
||||
struct bfd_link_hash_entry *bh;
|
||||
|
||||
/* We need to create .plt, .rela.plt, .got, and .rela.got sections. */
|
||||
|
||||
@ -1245,17 +1244,8 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
bh = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
|
||||
(bfd_vma) 0, (const char *) NULL, FALSE,
|
||||
get_elf_backend_data (abfd)->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared && ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
if (!_bfd_elf_define_linkage_sym (abfd, info, s,
|
||||
"_PROCEDURE_LINKAGE_TABLE_"))
|
||||
return FALSE;
|
||||
|
||||
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
||||
@ -1292,21 +1282,11 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
dynobj's .got section. We don't do this in the linker script
|
||||
because we don't want to define the symbol if we are not creating
|
||||
a global offset table. */
|
||||
bh = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL,
|
||||
alpha_elf_tdata(abfd)->got, (bfd_vma) 0, (const char *) NULL,
|
||||
FALSE, get_elf_backend_data (abfd)->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
|
||||
h = _bfd_elf_define_linkage_sym (abfd, info, alpha_elf_tdata(abfd)->got,
|
||||
"_GLOBAL_OFFSET_TABLE_");
|
||||
elf_hash_table (info)->hgot = h;
|
||||
if (h == NULL)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
106
bfd/elflink.c
106
bfd/elflink.c
@ -27,13 +27,51 @@
|
||||
#include "safe-ctype.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
/* Define a symbol in a dynamic linkage section. */
|
||||
|
||||
struct elf_link_hash_entry *
|
||||
_bfd_elf_define_linkage_sym (bfd *abfd,
|
||||
struct bfd_link_info *info,
|
||||
asection *sec,
|
||||
const char *name)
|
||||
{
|
||||
struct elf_link_hash_entry *h;
|
||||
struct bfd_link_hash_entry *bh;
|
||||
|
||||
h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
|
||||
if (h != NULL)
|
||||
{
|
||||
/* Zap symbol defined in an as-needed lib that wasn't linked.
|
||||
This is a symptom of a larger problem: Absolute symbols
|
||||
defined in shared libraries can't be overridden, because we
|
||||
lose the link to the bfd which is via the symbol section. */
|
||||
h->root.type = bfd_link_hash_new;
|
||||
}
|
||||
|
||||
bh = &h->root;
|
||||
if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
|
||||
sec, 0, NULL, FALSE,
|
||||
get_elf_backend_data (abfd)->collect,
|
||||
&bh))
|
||||
return NULL;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
|
||||
|
||||
if (!info->executable
|
||||
&& !bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return NULL;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
_bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
|
||||
{
|
||||
flagword flags;
|
||||
asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
struct bfd_link_hash_entry *bh;
|
||||
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
int ptralign;
|
||||
|
||||
@ -78,21 +116,10 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
|
||||
(or .got.plt) section. We don't do this in the linker script
|
||||
because we don't want to define the symbol if we are not creating
|
||||
a global offset table. */
|
||||
bh = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
|
||||
0, NULL, FALSE, bed->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
h->other = STV_HIDDEN;
|
||||
|
||||
if (! info->executable
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
|
||||
h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
|
||||
elf_hash_table (info)->hgot = h;
|
||||
if (h == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* The first bit of the global offset table is the header. */
|
||||
@ -132,8 +159,6 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
struct bfd_link_hash_entry *bh;
|
||||
const struct elf_backend_data *bed;
|
||||
|
||||
if (! is_elf_hash_table (info->hash))
|
||||
@ -212,27 +237,7 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
section. We don't want to define it if there is no .dynamic
|
||||
section, since on some ELF platforms the start up code examines it
|
||||
to decide how to initialize the process. */
|
||||
h = elf_link_hash_lookup (elf_hash_table (info), "_DYNAMIC",
|
||||
FALSE, FALSE, FALSE);
|
||||
if (h != NULL)
|
||||
{
|
||||
/* Zap symbol defined in an as-needed lib that wasn't linked.
|
||||
This is a symptom of a larger problem: Absolute symbols
|
||||
defined in shared libraries can't be overridden, because we
|
||||
lose the link to the bfd which is via the symbol section. */
|
||||
h->root.type = bfd_link_hash_new;
|
||||
}
|
||||
bh = &h->root;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_DYNAMIC", BSF_GLOBAL, s, 0, NULL, FALSE,
|
||||
get_elf_backend_data (abfd)->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (! info->executable
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
if (!_bfd_elf_define_linkage_sym (abfd, info, s, "_DYNAMIC"))
|
||||
return FALSE;
|
||||
|
||||
s = bfd_make_section_with_flags (abfd, ".hash",
|
||||
@ -282,25 +287,12 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
|
||||
|| ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
|
||||
return FALSE;
|
||||
|
||||
if (bed->want_plt_sym)
|
||||
{
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
struct elf_link_hash_entry *h;
|
||||
struct bfd_link_hash_entry *bh = NULL;
|
||||
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 0, NULL,
|
||||
FALSE, get_elf_backend_data (abfd)->collect, &bh)))
|
||||
return FALSE;
|
||||
h = (struct elf_link_hash_entry *) bh;
|
||||
h->def_regular = 1;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (! info->executable
|
||||
&& ! bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return FALSE;
|
||||
}
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
if (bed->want_plt_sym
|
||||
&& !_bfd_elf_define_linkage_sym (abfd, info, s,
|
||||
"_PROCEDURE_LINKAGE_TABLE_"))
|
||||
return FALSE;
|
||||
|
||||
s = bfd_make_section_with_flags (abfd,
|
||||
(bed->default_use_rela_p
|
||||
|
Loading…
Reference in New Issue
Block a user