aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorWalter Lee <walt@tilera.com>2012-08-28 06:28:31 +0000
committerWalter Lee <walt@tilera.com>2012-08-28 06:28:31 +0000
commit663b5850121926ab9d7685c4c4f2961ab65adcb8 (patch)
tree40b695eafb405e53120578af6d9dd8d502954bb8 /bfd
parente5b95258d9dd1ecc4a53baf56308ce78f19f4904 (diff)
downloadgdb-663b5850121926ab9d7685c4c4f2961ab65adcb8.zip
gdb-663b5850121926ab9d7685c4c4f2961ab65adcb8.tar.gz
gdb-663b5850121926ab9d7685c4c4f2961ab65adcb8.tar.bz2
Add padding to the plt section so that its size is a multiple of its
entry size. * elf32-tilepro.c (allocate_dynrelocs): Use PLT_ENTRY_SIZE as size of header. (tilepro_plt_entry_build): Account for new header size. (tilepro_elf_finish_dynamic_sections): Ditto. (tilepro_elf_plt_sym_val): Ditto. * elfxx-tilegx.c (allocate_dynrelocs): Use PLT_ENTRY_SIZE as size of header + tail. (tilegx_elf_finish_dynamic_sections): Account for new padding.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog11
-rw-r--r--bfd/elf32-tilepro.c12
-rw-r--r--bfd/elfxx-tilegx.c12
3 files changed, 28 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0107ea1..2165b0c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,14 @@
+2012-08-28 Walter Lee <walt@tilera.com>
+
+ * elf32-tilepro.c (allocate_dynrelocs): Use PLT_ENTRY_SIZE as size
+ of header.
+ (tilepro_plt_entry_build): Account for new header size.
+ (tilepro_elf_finish_dynamic_sections): Ditto.
+ (tilepro_elf_plt_sym_val): Ditto.
+ * elfxx-tilegx.c (allocate_dynrelocs): Use PLT_ENTRY_SIZE as size
+ of header + tail.
+ (tilegx_elf_finish_dynamic_sections): Account for new padding.
+
2012-08-27 Walter Lee <walt@tilera.com>
* reloc.c (Add BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL,
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index fa883e1..aa2dfd6 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -1105,7 +1105,7 @@ static int
tilepro_plt_entry_build (asection *splt, asection *sgotplt, bfd_vma offset,
bfd_vma *r_offset)
{
- int plt_index = (offset - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;
+ int plt_index = (offset - PLT_ENTRY_SIZE) / PLT_ENTRY_SIZE;
int got_offset = plt_index * GOT_ENTRY_SIZE + GOTPLT_HEADER_SIZE;
tilepro_bundle_bits *pc;
@@ -2193,7 +2193,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* Allocate room for the header. */
if (s->size == 0)
{
- s->size = PLT_HEADER_SIZE;
+ s->size = PLT_ENTRY_SIZE;
}
h->plt.offset = s->size;
@@ -3867,7 +3867,11 @@ tilepro_elf_finish_dynamic_sections (bfd *output_bfd,
/* Fill in the first entry in the procedure linkage table. */
if (splt->size > 0)
- memcpy (splt->contents, tilepro_plt0_entry, PLT_HEADER_SIZE);
+ {
+ memcpy (splt->contents, tilepro_plt0_entry, PLT_HEADER_SIZE);
+ memset (splt->contents + PLT_HEADER_SIZE, 0,
+ PLT_ENTRY_SIZE - PLT_HEADER_SIZE);
+ }
elf_section_data (splt->output_section)->this_hdr.sh_entsize
= PLT_ENTRY_SIZE;
@@ -3924,7 +3928,7 @@ static bfd_vma
tilepro_elf_plt_sym_val (bfd_vma i, const asection *plt,
const arelent *rel ATTRIBUTE_UNUSED)
{
- return plt->vma + PLT_HEADER_SIZE + i * PLT_ENTRY_SIZE;
+ return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
}
static enum elf_reloc_type_class
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index 1f5c458..c0daf18 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -2470,10 +2470,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* Allocate room for the header and tail. */
if (s->size == 0)
{
- s->size = PLT_HEADER_SIZE + PLT_TAIL_SIZE;
+ s->size = PLT_ENTRY_SIZE;
}
- h->plt.offset = s->size - PLT_TAIL_SIZE;
+ h->plt.offset = s->size - PLT_ENTRY_SIZE + PLT_HEADER_SIZE;
/* If this symbol is not defined in a regular file, and we are
not generating a shared library, then set the symbol to this
@@ -4247,6 +4247,7 @@ tilegx_elf_finish_dynamic_sections (bfd *output_bfd,
bfd *dynobj;
asection *sdyn;
struct tilegx_elf_link_hash_table *htab;
+ size_t pad_size;
htab = tilegx_elf_hash_table (info);
BFD_ASSERT (htab != NULL);
@@ -4275,10 +4276,15 @@ tilegx_elf_finish_dynamic_sections (bfd *output_bfd,
tilegx64_plt0_entry : tilegx32_plt0_entry,
PLT_HEADER_SIZE);
- memcpy (splt->contents + splt->size - PLT_TAIL_SIZE,
+ memcpy (splt->contents + splt->size
+ - PLT_ENTRY_SIZE + PLT_HEADER_SIZE,
ABI_64_P (output_bfd) ?
tilegx64_plt_tail_entry : tilegx32_plt_tail_entry,
PLT_TAIL_SIZE);
+ /* Add padding so that the plt section is a multiple of its
+ entry size. */
+ pad_size = PLT_ENTRY_SIZE - PLT_HEADER_SIZE - PLT_TAIL_SIZE;
+ memset (splt->contents + splt->size - pad_size, 0, pad_size);
}
elf_section_data (splt->output_section)->this_hdr.sh_entsize