aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2009-05-29 18:30:30 +0000
committerH.J. Lu <hjl.tools@gmail.com>2009-05-29 18:30:30 +0000
commiteb4ff4d67f23a5572fce03bbf06a7bf34a0b11e6 (patch)
treed1ff3089a75101bef1aa435fe61cb90225a3d54d
parent3d22076f965f5faf9f2cf9f2302227513db7f80a (diff)
downloadgdb-eb4ff4d67f23a5572fce03bbf06a7bf34a0b11e6.zip
gdb-eb4ff4d67f23a5572fce03bbf06a7bf34a0b11e6.tar.gz
gdb-eb4ff4d67f23a5572fce03bbf06a7bf34a0b11e6.tar.bz2
2009-05-29 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (link_hash_newfunc): Add elf_i386_ prefix. (create_got_section): Likewise. (allocate_dynrelocs): Likewise. (readonly_dynrelocs): Likewise. (set_tls_module_base): Likewise. (dtpoff_base): Likewise. (tpoff): Likewise. (elf_i386_link_hash_table_create): Updated. (elf_i386_create_dynamic_sections): Likewise. (elf_i386_check_relocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. * elf64-x86-64.c (link_hash_newfunc): Add elf64_x86_64_ prefix. (create_got_section): Likewise. (allocate_dynrelocs): Likewise. (readonly_dynrelocs): Likewise. (set_tls_module_base): Likewise. (dtpoff_base): Likewise. (tpoff): Likewise. (elf64_x86_64_link_hash_table_create): Updated. (elf64_x86_64_create_dynamic_sections): Likewise. (elf64_x86_64_check_relocs): Likewise. (elf64_x86_64_size_dynamic_sections): Likewise. (elf64_x86_64_relocate_section): Likewise.
-rw-r--r--bfd/ChangeLog28
-rw-r--r--bfd/elf32-i386.c68
-rw-r--r--bfd/elf64-x86-64.c55
3 files changed, 97 insertions, 54 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 774dc3f..24800c5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,31 @@
+2009-05-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf32-i386.c (link_hash_newfunc): Add elf_i386_ prefix.
+ (create_got_section): Likewise.
+ (allocate_dynrelocs): Likewise.
+ (readonly_dynrelocs): Likewise.
+ (set_tls_module_base): Likewise.
+ (dtpoff_base): Likewise.
+ (tpoff): Likewise.
+ (elf_i386_link_hash_table_create): Updated.
+ (elf_i386_create_dynamic_sections): Likewise.
+ (elf_i386_check_relocs): Likewise.
+ (elf_i386_size_dynamic_sections): Likewise.
+ (elf_i386_relocate_section): Likewise.
+
+ * elf64-x86-64.c (link_hash_newfunc): Add elf64_x86_64_ prefix.
+ (create_got_section): Likewise.
+ (allocate_dynrelocs): Likewise.
+ (readonly_dynrelocs): Likewise.
+ (set_tls_module_base): Likewise.
+ (dtpoff_base): Likewise.
+ (tpoff): Likewise.
+ (elf64_x86_64_link_hash_table_create): Updated.
+ (elf64_x86_64_create_dynamic_sections): Likewise.
+ (elf64_x86_64_check_relocs): Likewise.
+ (elf64_x86_64_size_dynamic_sections): Likewise.
+ (elf64_x86_64_relocate_section): Likewise.
+
2009-05-28 Nick Clifton <nickc@redhat.com>
* targets.c (_bfd_target_vector): Only include plugin target in
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 88aa1ec..8499f7e 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -708,9 +708,9 @@ struct elf_i386_link_hash_table
/* Create an entry in an i386 ELF linker hash table. */
static struct bfd_hash_entry *
-link_hash_newfunc (struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string)
+elf_i386_link_hash_newfunc (struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string)
{
/* Allocate the structure if it has not already been allocated by a
subclass. */
@@ -749,7 +749,8 @@ elf_i386_link_hash_table_create (bfd *abfd)
if (ret == NULL)
return NULL;
- if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
+ elf_i386_link_hash_newfunc,
sizeof (struct elf_i386_link_hash_entry)))
{
free (ret);
@@ -779,7 +780,7 @@ elf_i386_link_hash_table_create (bfd *abfd)
shortcuts to them in our hash table. */
static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
+elf_i386_create_got_section (bfd *dynobj, struct bfd_link_info *info)
{
struct elf_i386_link_hash_table *htab;
@@ -814,7 +815,7 @@ elf_i386_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
struct elf_i386_link_hash_table *htab;
htab = elf_i386_hash_table (info);
- if (!htab->sgot && !create_got_section (dynobj, info))
+ if (!htab->sgot && !elf_i386_create_got_section (dynobj, info))
return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
@@ -1389,7 +1390,7 @@ elf_i386_check_relocs (bfd *abfd,
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
- if (!create_got_section (htab->elf.dynobj, info))
+ if (!elf_i386_create_got_section (htab->elf.dynobj, info))
return FALSE;
}
if (r_type != R_386_TLS_IE)
@@ -1815,7 +1816,7 @@ elf_i386_adjust_dynamic_symbol (struct bfd_link_info *info,
dynamic relocs. */
static bfd_boolean
-allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
+elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
struct bfd_link_info *info;
struct elf_i386_link_hash_table *htab;
@@ -2106,7 +2107,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* Find any dynamic relocs that apply to read-only sections. */
static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
+elf_i386_readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
{
struct elf_i386_link_hash_entry *eh;
struct elf_i386_dyn_relocs *p;
@@ -2275,7 +2276,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
/* Allocate global sym .plt and .got entries, and space for global
sym dynamic relocs. */
- elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf, elf_i386_allocate_dynrelocs, info);
/* For every jump slot reserved in the sgotplt, reloc_count is
incremented. However, when we reserve space for TLS descriptors,
@@ -2388,7 +2389,8 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf,
+ elf_i386_readonly_dynrelocs, info);
if ((info->flags & DF_TEXTREL) != 0)
{
@@ -2483,7 +2485,7 @@ elf_i386_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
multiple times, it is idempotent. */
static void
-set_tls_module_base (struct bfd_link_info *info)
+elf_i386_set_tls_module_base (struct bfd_link_info *info)
{
struct bfd_link_hash_entry *base;
@@ -2503,7 +2505,7 @@ set_tls_module_base (struct bfd_link_info *info)
This is PT_TLS segment p_vaddr. */
static bfd_vma
-dtpoff_base (struct bfd_link_info *info)
+elf_i386_dtpoff_base (struct bfd_link_info *info)
{
/* If tls_sec is NULL, we should have signalled an error already. */
if (elf_hash_table (info)->tls_sec == NULL)
@@ -2515,7 +2517,7 @@ dtpoff_base (struct bfd_link_info *info)
if STT_TLS virtual address is ADDRESS. */
static bfd_vma
-tpoff (struct bfd_link_info *info, bfd_vma address)
+elf_i386_tpoff (struct bfd_link_info *info, bfd_vma address)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
@@ -2559,7 +2561,7 @@ elf_i386_relocate_section (bfd *output_bfd,
&& !strcmp (input_section->output_section->name,
".tls_vars"));
- set_tls_module_base (info);
+ elf_i386_set_tls_module_base (info);
rel = relocs;
relend = relocs + input_section->reloc_count;
@@ -3048,7 +3050,7 @@ elf_i386_relocate_section (bfd *output_bfd,
"\x65\xa1\0\0\0\0\x81\xe8\0\0\0", 12);
roff = rel->r_offset + 6;
}
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd, elf_i386_tpoff (info, relocation),
contents + roff);
/* Skip R_386_PC32/R_386_PLT32. */
rel++;
@@ -3075,7 +3077,7 @@ elf_i386_relocate_section (bfd *output_bfd,
below with 0x86. */
bfd_put_8 (output_bfd, val ^ 0x86,
contents + roff - 1);
- bfd_put_32 (output_bfd, -tpoff (info, relocation),
+ bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + roff);
continue;
}
@@ -3143,7 +3145,7 @@ elf_i386_relocate_section (bfd *output_bfd,
break;
}
}
- bfd_put_32 (output_bfd, -tpoff (info, relocation),
+ bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
continue;
}
@@ -3189,10 +3191,10 @@ elf_i386_relocate_section (bfd *output_bfd,
else
BFD_FAIL ();
if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTIE)
- bfd_put_32 (output_bfd, -tpoff (info, relocation),
+ bfd_put_32 (output_bfd, -elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
else
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd, elf_i386_tpoff (info, relocation),
contents + rel->r_offset);
continue;
}
@@ -3249,7 +3251,7 @@ elf_i386_relocate_section (bfd *output_bfd,
{
BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd,
- relocation - dtpoff_base (info),
+ relocation - elf_i386_dtpoff_base (info),
htab->sgotplt->contents + offplt
+ htab->sgotplt_jump_table_size + 4);
}
@@ -3276,10 +3278,12 @@ elf_i386_relocate_section (bfd *output_bfd,
dr_type = R_386_TLS_TPOFF32;
if (dr_type == R_386_TLS_TPOFF && indx == 0)
- bfd_put_32 (output_bfd, relocation - dtpoff_base (info),
+ bfd_put_32 (output_bfd,
+ relocation - elf_i386_dtpoff_base (info),
htab->sgot->contents + off);
else if (dr_type == R_386_TLS_TPOFF32 && indx == 0)
- bfd_put_32 (output_bfd, dtpoff_base (info) - relocation,
+ bfd_put_32 (output_bfd,
+ elf_i386_dtpoff_base (info) - relocation,
htab->sgot->contents + off);
else if (dr_type != R_386_TLS_DESC)
bfd_put_32 (output_bfd, 0,
@@ -3298,7 +3302,7 @@ elf_i386_relocate_section (bfd *output_bfd,
{
BFD_ASSERT (! unresolved_reloc);
bfd_put_32 (output_bfd,
- relocation - dtpoff_base (info),
+ relocation - elf_i386_dtpoff_base (info),
htab->sgot->contents + off + 4);
}
else
@@ -3318,7 +3322,9 @@ elf_i386_relocate_section (bfd *output_bfd,
else if (tls_type == GOT_TLS_IE_BOTH)
{
bfd_put_32 (output_bfd,
- indx == 0 ? relocation - dtpoff_base (info) : 0,
+ (indx == 0
+ ? relocation - elf_i386_dtpoff_base (info)
+ : 0),
htab->sgot->contents + off + 4);
outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF);
outrel.r_offset += 4;
@@ -3533,10 +3539,10 @@ elf_i386_relocate_section (bfd *output_bfd,
case R_386_TLS_LDO_32:
if (info->shared || (input_section->flags & SEC_CODE) == 0)
- relocation -= dtpoff_base (info);
+ relocation -= elf_i386_dtpoff_base (info);
else
/* When converting LDO to LE, we must negate. */
- relocation = -tpoff (info, relocation);
+ relocation = -elf_i386_tpoff (info, relocation);
break;
case R_386_TLS_LE_32:
@@ -3568,14 +3574,14 @@ elf_i386_relocate_section (bfd *output_bfd,
if (indx)
continue;
else if (r_type == R_386_TLS_LE_32)
- relocation = dtpoff_base (info) - relocation;
+ relocation = elf_i386_dtpoff_base (info) - relocation;
else
- relocation -= dtpoff_base (info);
+ relocation -= elf_i386_dtpoff_base (info);
}
else if (r_type == R_386_TLS_LE_32)
- relocation = tpoff (info, relocation);
+ relocation = elf_i386_tpoff (info, relocation);
else
- relocation = -tpoff (info, relocation);
+ relocation = -elf_i386_tpoff (info, relocation);
break;
default:
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 6b7f17a..253473f 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -525,8 +525,9 @@ struct elf64_x86_64_link_hash_table
/* Create an entry in an x86-64 ELF linker hash table. */
static struct bfd_hash_entry *
-link_hash_newfunc (struct bfd_hash_entry *entry, struct bfd_hash_table *table,
- const char *string)
+elf64_x86_64_link_hash_newfunc (struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string)
{
/* Allocate the structure if it has not already been allocated by a
subclass. */
@@ -565,7 +566,8 @@ elf64_x86_64_link_hash_table_create (bfd *abfd)
if (ret == NULL)
return NULL;
- if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
+ elf64_x86_64_link_hash_newfunc,
sizeof (struct elf64_x86_64_link_hash_entry)))
{
free (ret);
@@ -593,7 +595,7 @@ elf64_x86_64_link_hash_table_create (bfd *abfd)
shortcuts to them in our hash table. */
static bfd_boolean
-create_got_section (bfd *dynobj, struct bfd_link_info *info)
+elf64_x86_64_create_got_section (bfd *dynobj, struct bfd_link_info *info)
{
struct elf64_x86_64_link_hash_table *htab;
@@ -628,7 +630,7 @@ elf64_x86_64_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
struct elf64_x86_64_link_hash_table *htab;
htab = elf64_x86_64_hash_table (info);
- if (!htab->sgot && !create_got_section (dynobj, info))
+ if (!htab->sgot && !elf64_x86_64_create_got_section (dynobj, info))
return FALSE;
if (!_bfd_elf_create_dynamic_sections (dynobj, info))
@@ -1168,7 +1170,8 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
{
if (htab->elf.dynobj == NULL)
htab->elf.dynobj = abfd;
- if (!create_got_section (htab->elf.dynobj, info))
+ if (!elf64_x86_64_create_got_section (htab->elf.dynobj,
+ info))
return FALSE;
}
break;
@@ -1650,7 +1653,7 @@ elf64_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
dynamic relocs. */
static bfd_boolean
-allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+elf64_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct bfd_link_info *info;
struct elf64_x86_64_link_hash_table *htab;
@@ -1903,7 +1906,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
/* Find any dynamic relocs that apply to read-only sections. */
static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
+elf64_x86_64_readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
struct elf64_x86_64_link_hash_entry *eh;
struct elf64_x86_64_dyn_relocs *p;
@@ -2065,7 +2068,8 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
/* Allocate global sym .plt and .got entries, and space for global
sym dynamic relocs. */
- elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf, elf64_x86_64_allocate_dynrelocs,
+ info);
/* For every jump slot reserved in the sgotplt, reloc_count is
incremented. However, when we reserve space for TLS descriptors,
@@ -2196,7 +2200,9 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0)
- elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
+ elf_link_hash_traverse (&htab->elf,
+ elf64_x86_64_readonly_dynrelocs,
+ info);
if ((info->flags & DF_TEXTREL) != 0)
{
@@ -2254,7 +2260,7 @@ elf64_x86_64_always_size_sections (bfd *output_bfd,
multiple times, it is idempotent. */
static void
-set_tls_module_base (struct bfd_link_info *info)
+elf64_x86_64_set_tls_module_base (struct bfd_link_info *info)
{
struct bfd_link_hash_entry *base;
@@ -2274,7 +2280,7 @@ set_tls_module_base (struct bfd_link_info *info)
This is PT_TLS segment p_vaddr. */
static bfd_vma
-dtpoff_base (struct bfd_link_info *info)
+elf64_x86_64_dtpoff_base (struct bfd_link_info *info)
{
/* If tls_sec is NULL, we should have signalled an error already. */
if (elf_hash_table (info)->tls_sec == NULL)
@@ -2286,7 +2292,7 @@ dtpoff_base (struct bfd_link_info *info)
if STT_TLS virtual address is ADDRESS. */
static bfd_vma
-tpoff (struct bfd_link_info *info, bfd_vma address)
+elf64_x86_64_tpoff (struct bfd_link_info *info, bfd_vma address)
{
struct elf_link_hash_table *htab = elf_hash_table (info);
@@ -2339,7 +2345,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
local_got_offsets = elf_local_got_offsets (input_bfd);
local_tlsdesc_gotents = elf64_x86_64_local_tlsdesc_gotent (input_bfd);
- set_tls_module_base (info);
+ elf64_x86_64_set_tls_module_base (info);
rel = relocs;
relend = relocs + input_section->reloc_count;
@@ -2852,7 +2858,8 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
memcpy (contents + roff - 4,
"\x64\x48\x8b\x04\x25\0\0\0\0\x48\x8d\x80\0\0\0",
16);
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd,
+ elf64_x86_64_tpoff (info, relocation),
contents + roff + 8);
/* Skip R_X86_64_PC32/R_X86_64_PLT32. */
rel++;
@@ -2878,7 +2885,8 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
bfd_put_8 (output_bfd, 0xc7, contents + roff - 2);
bfd_put_8 (output_bfd, 0xc0 | ((val >> 3) & 7),
contents + roff - 1);
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd,
+ elf64_x86_64_tpoff (info, relocation),
contents + roff);
continue;
}
@@ -2944,7 +2952,8 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
bfd_put_8 (output_bfd, 0x80 | reg | (reg << 3),
contents + roff - 1);
}
- bfd_put_32 (output_bfd, tpoff (info, relocation),
+ bfd_put_32 (output_bfd,
+ elf64_x86_64_tpoff (info, relocation),
contents + roff);
continue;
}
@@ -2999,7 +3008,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
BFD_ASSERT (loc + sizeof (Elf64_External_Rela)
<= sreloc->contents + sreloc->size);
if (indx == 0)
- outrel.r_addend = relocation - dtpoff_base (info);
+ outrel.r_addend = relocation - elf64_x86_64_dtpoff_base (info);
else
outrel.r_addend = 0;
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
@@ -3021,7 +3030,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
outrel.r_addend = 0;
if ((dr_type == R_X86_64_TPOFF64
|| dr_type == R_X86_64_TLSDESC) && indx == 0)
- outrel.r_addend = relocation - dtpoff_base (info);
+ outrel.r_addend = relocation - elf64_x86_64_dtpoff_base (info);
outrel.r_info = ELF64_R_INFO (indx, dr_type);
loc = sreloc->contents;
@@ -3036,7 +3045,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
{
BFD_ASSERT (! unresolved_reloc);
bfd_put_64 (output_bfd,
- relocation - dtpoff_base (info),
+ relocation - elf64_x86_64_dtpoff_base (info),
htab->sgot->contents + off + GOT_ENTRY_SIZE);
}
else
@@ -3216,14 +3225,14 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
case R_X86_64_DTPOFF32:
if (info->shared || (input_section->flags & SEC_CODE) == 0)
- relocation -= dtpoff_base (info);
+ relocation -= elf64_x86_64_dtpoff_base (info);
else
- relocation = tpoff (info, relocation);
+ relocation = elf64_x86_64_tpoff (info, relocation);
break;
case R_X86_64_TPOFF32:
BFD_ASSERT (! info->shared);
- relocation = tpoff (info, relocation);
+ relocation = elf64_x86_64_tpoff (info, relocation);
break;
default: