This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Minor ELF32/ia64 cleanup
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Tue, 3 May 2005 12:21:21 -0700
- Subject: PATCH: Minor ELF32/ia64 cleanup
This patch removes some 64bit assumptions.
H.J.
---
2005-05-03 H.J. Lu <hongjiu.lu@intel.com>
* elfxx-ia64.c (ARCH_SIZE): New.
(LOG_SECTION_ALIGN): Likewise.
(elfNN_ia64_create_dynamic_sections): Use LOG_SECTION_ALIGN to
align relocation sections.
(get_fptr): Likewise.
(get_reloc_section): Likewise.
(elfNN_ia64_tprel_base): Likewise.
(elfNN_ia64_check_relocs): Support 32bit relocations.
(allocate_global_fptr_got): Likewise.
(allocate_dynrel_entries): Likewise.
(set_got_entry): Likewise.
(set_pltoff_entry): Likewise.
(elfNN_ia64_relocate_section): Likewise.
--- bfd/elfxx-ia64.c 2005-03-11 11:43:40.000000000 -0800
+++ bfd/elfxx-ia64.c 2005-03-12 08:49:06.000000000 -0800
@@ -27,6 +27,16 @@
#include "objalloc.h"
#include "hashtab.h"
+#define ARCH_SIZE NN
+
+#if ARCH_SIZE == 64
+#define LOG_SECTION_ALIGN 3
+#endif
+
+#if ARCH_SIZE == 32
+#define LOG_SECTION_ALIGN 2
+#endif
+
/* THE RULES for all the stuff the linker creates --
GOT Entries created in response to LTOFF or LTOFF_FPTR
@@ -1896,7 +1906,7 @@ elfNN_ia64_create_dynamic_sections (abfd
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY))
- || !bfd_set_section_alignment (abfd, s, 3))
+ || !bfd_set_section_alignment (abfd, s, LOG_SECTION_ALIGN))
return FALSE;
ia64_info->rel_pltoff_sec = s;
@@ -1907,7 +1917,7 @@ elfNN_ia64_create_dynamic_sections (abfd
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY))
- || !bfd_set_section_alignment (abfd, s, 3))
+ || !bfd_set_section_alignment (abfd, s, LOG_SECTION_ALIGN))
return FALSE;
ia64_info->rel_got_sec = s;
@@ -2081,7 +2091,8 @@ get_fptr (abfd, info, ia64_info)
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY))
- || !bfd_set_section_alignment (abfd, fptr_rel, 3))
+ || !bfd_set_section_alignment (abfd, fptr_rel,
+ LOG_SECTION_ALIGN))
{
BFD_ASSERT (0);
return NULL;
@@ -2171,7 +2182,8 @@ get_reloc_section (abfd, ia64_info, sec,
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY))
- || !bfd_set_section_alignment (dynobj, srel, 3))
+ || !bfd_set_section_alignment (dynobj, srel,
+ LOG_SECTION_ALIGN))
return NULL;
}
@@ -2294,11 +2306,13 @@ elfNN_ia64_check_relocs (abfd, info, sec
info->flags |= DF_STATIC_TLS;
break;
+ case R_IA64_DTPREL32MSB:
+ case R_IA64_DTPREL32LSB:
case R_IA64_DTPREL64MSB:
case R_IA64_DTPREL64LSB:
if (info->shared || maybe_dynamic)
need_entry = NEED_DYNREL;
- dynrel_type = R_IA64_DTPREL64LSB;
+ dynrel_type = R_IA64_DTPRELNNLSB;
break;
case R_IA64_LTOFF_DTPREL22:
@@ -2334,7 +2348,7 @@ elfNN_ia64_check_relocs (abfd, info, sec
need_entry = NEED_FPTR | NEED_DYNREL;
else
need_entry = NEED_FPTR;
- dynrel_type = R_IA64_FPTR64LSB;
+ dynrel_type = R_IA64_FPTRNNLSB;
break;
case R_IA64_LTOFF22:
@@ -2384,7 +2398,7 @@ elfNN_ia64_check_relocs (abfd, info, sec
/* Shared objects will always need at least a REL relocation. */
if (info->shared || maybe_dynamic)
need_entry = NEED_DYNREL;
- dynrel_type = R_IA64_DIR64LSB;
+ dynrel_type = R_IA64_DIRNNLSB;
break;
case R_IA64_IPLTMSB:
@@ -2403,7 +2417,7 @@ elfNN_ia64_check_relocs (abfd, info, sec
case R_IA64_PCREL64LSB:
if (maybe_dynamic)
need_entry = NEED_DYNREL;
- dynrel_type = R_IA64_PCREL64LSB;
+ dynrel_type = R_IA64_PCRELNNLSB;
break;
}
@@ -2556,7 +2570,7 @@ allocate_global_fptr_got (dyn_i, data)
if (dyn_i->want_got
&& dyn_i->want_fptr
- && elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info, R_IA64_FPTR64LSB))
+ && elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info, R_IA64_FPTRNNLSB))
{
dyn_i->got_offset = x->ofs;
x->ofs += 8;
@@ -2763,6 +2777,7 @@ allocate_dynrel_entries (dyn_i, data)
switch (rent->type)
{
+ case R_IA64_FPTR32LSB:
case R_IA64_FPTR64LSB:
/* Allocate one iff !want_fptr and not PIE, which by this point
will be true only if we're actually allocating one statically
@@ -2771,10 +2786,12 @@ allocate_dynrel_entries (dyn_i, data)
if (dyn_i->want_fptr && !x->info->pie)
continue;
break;
+ case R_IA64_PCREL32LSB:
case R_IA64_PCREL64LSB:
if (!dynamic_symbol)
continue;
break;
+ case R_IA64_DIR32LSB:
case R_IA64_DIR64LSB:
if (!dynamic_symbol && !shared)
continue;
@@ -2787,6 +2804,7 @@ allocate_dynrel_entries (dyn_i, data)
if (!dynamic_symbol)
count *= 2;
break;
+ case R_IA64_DTPREL32LSB:
case R_IA64_TPREL64LSB:
case R_IA64_DTPREL64LSB:
case R_IA64_DTPMOD64LSB:
@@ -3423,6 +3441,7 @@ set_got_entry (abfd, info, dyn_i, dynind
}
got_offset = dyn_i->dtpmod_offset;
break;
+ case R_IA64_DTPREL32LSB:
case R_IA64_DTPREL64LSB:
done = dyn_i->dtprel_done;
dyn_i->dtprel_done = TRUE;
@@ -3447,9 +3466,12 @@ set_got_entry (abfd, info, dyn_i, dynind
&& (!dyn_i->h
|| ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
|| dyn_i->h->root.type != bfd_link_hash_undefweak)
+ && dyn_r_type != R_IA64_DTPREL32LSB
&& dyn_r_type != R_IA64_DTPREL64LSB)
|| elfNN_ia64_dynamic_symbol_p (dyn_i->h, info, dyn_r_type)
- || (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB))
+ || (dynindx != -1
+ && (dyn_r_type == R_IA64_FPTR32LSB
+ || dyn_r_type == R_IA64_FPTR64LSB)))
&& (!dyn_i->want_ltoff_fptr
|| !info->pie
|| !dyn_i->h
@@ -3458,9 +3480,10 @@ set_got_entry (abfd, info, dyn_i, dynind
if (dynindx == -1
&& dyn_r_type != R_IA64_TPREL64LSB
&& dyn_r_type != R_IA64_DTPMOD64LSB
+ && dyn_r_type != R_IA64_DTPREL32LSB
&& dyn_r_type != R_IA64_DTPREL64LSB)
{
- dyn_r_type = R_IA64_REL64LSB;
+ dyn_r_type = R_IA64_RELNNLSB;
dynindx = 0;
addend = value;
}
@@ -3469,6 +3492,18 @@ set_got_entry (abfd, info, dyn_i, dynind
{
switch (dyn_r_type)
{
+ case R_IA64_REL32LSB:
+ dyn_r_type = R_IA64_REL32MSB;
+ break;
+ case R_IA64_DIR32LSB:
+ dyn_r_type = R_IA64_DIR32MSB;
+ break;
+ case R_IA64_FPTR32LSB:
+ dyn_r_type = R_IA64_FPTR32MSB;
+ break;
+ case R_IA64_DTPREL32LSB:
+ dyn_r_type = R_IA64_DTPREL32MSB;
+ break;
case R_IA64_REL64LSB:
dyn_r_type = R_IA64_REL64MSB;
break;
@@ -3598,9 +3633,9 @@ set_pltoff_entry (abfd, info, dyn_i, val
unsigned int dyn_r_type;
if (bfd_big_endian (abfd))
- dyn_r_type = R_IA64_REL64MSB;
+ dyn_r_type = R_IA64_RELNNMSB;
else
- dyn_r_type = R_IA64_REL64LSB;
+ dyn_r_type = R_IA64_RELNNLSB;
elfNN_ia64_install_dyn_reloc (abfd, NULL, pltoff_sec,
ia64_info->rel_pltoff_sec,
@@ -3608,7 +3643,7 @@ set_pltoff_entry (abfd, info, dyn_i, val
dyn_r_type, 0, value);
elfNN_ia64_install_dyn_reloc (abfd, NULL, pltoff_sec,
ia64_info->rel_pltoff_sec,
- dyn_i->pltoff_offset + 8,
+ dyn_i->pltoff_offset + ARCH_SIZE / 8,
dyn_r_type, 0, gp);
}
@@ -3626,7 +3661,7 @@ set_pltoff_entry (abfd, info, dyn_i, val
/* Return the base VMA address which should be subtracted from real addresses
when resolving @tprel() relocation.
Main program TLS (whose template starts at PT_TLS p_vaddr)
- is assigned offset round(16, PT_TLS p_align). */
+ is assigned offset round(2 * size of pointer, PT_TLS p_align). */
static bfd_vma
elfNN_ia64_tprel_base (info)
@@ -3635,7 +3670,8 @@ elfNN_ia64_tprel_base (info)
asection *tls_sec = elf_hash_table (info)->tls_sec;
BFD_ASSERT (tls_sec != NULL);
- return tls_sec->vma - align_power ((bfd_vma) 16, tls_sec->alignment_power);
+ return tls_sec->vma - align_power ((bfd_vma) ARCH_SIZE / 4,
+ tls_sec->alignment_power);
}
/* Return the base VMA address which should be subtracted from real addresses
@@ -4102,7 +4138,7 @@ elfNN_ia64_relocate_section (output_bfd,
case R_IA64_LTOFF64I:
dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
value = set_got_entry (input_bfd, info, dyn_i, (h ? h->dynindx : -1),
- rel->r_addend, value, R_IA64_DIR64LSB);
+ rel->r_addend, value, R_IA64_DIRNNLSB);
value -= gp_val;
r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
break;
@@ -4155,7 +4191,7 @@ elfNN_ia64_relocate_section (output_bfd,
}
dynindx = 0;
addend = value;
- dyn_r_type = r_type + R_IA64_REL64LSB - R_IA64_FPTR64LSB;
+ dyn_r_type = r_type + R_IA64_RELNNLSB - R_IA64_FPTRNNLSB;
}
else if (h)
{
@@ -4219,7 +4255,7 @@ elfNN_ia64_relocate_section (output_bfd,
}
value = set_got_entry (output_bfd, info, dyn_i, dynindx,
- rel->r_addend, value, R_IA64_FPTR64LSB);
+ rel->r_addend, value, R_IA64_FPTRNNLSB);
value -= gp_val;
r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type);
}
@@ -4417,6 +4453,8 @@ elfNN_ia64_relocate_section (output_bfd,
case R_IA64_DTPREL14:
case R_IA64_DTPREL22:
case R_IA64_DTPREL64I:
+ case R_IA64_DTPREL32LSB:
+ case R_IA64_DTPREL32MSB:
case R_IA64_DTPREL64LSB:
case R_IA64_DTPREL64MSB:
value -= elfNN_ia64_dtprel_base (info);
@@ -4455,7 +4493,7 @@ elfNN_ia64_relocate_section (output_bfd,
case R_IA64_LTOFF_DTPREL22:
if (!dynamic_symbol_p)
value -= elfNN_ia64_dtprel_base (info);
- got_r_type = R_IA64_DTPREL64LSB;
+ got_r_type = R_IA64_DTPRELNNLSB;
break;
}
dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);