aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.cross7
-rw-r--r--src/arch-arm.c183
-rw-r--r--src/dso.c4
-rw-r--r--src/get.c1
4 files changed, 191 insertions, 4 deletions
diff --git a/ChangeLog.cross b/ChangeLog.cross
index 4304654..0eac7ae 100644
--- a/ChangeLog.cross
+++ b/ChangeLog.cross
@@ -1,4 +1,11 @@
2006-08-08 CodeSourcery, LLC.
+
+ * arch-arm.c: add ARM EABI support, dynamic_linker_alt
+ * src/dso.c: STT_ARM_TFUNC support
+ * src/get.c: ld-linux.so.3 to the list of ldso names
+
+2006-08-08 CodeSourcery, LLC.
+
* gather.c: add new dynamic_linker_alt
* prelink.h: ditto
diff --git a/src/arch-arm.c b/src/arch-arm.c
index 09d0f68..24766ab 100644
--- a/src/arch-arm.c
+++ b/src/arch-arm.c
@@ -28,6 +28,12 @@
#include "prelink.h"
+#ifndef R_ARM_TLS_DTPMOD32
+#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */
+#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */
+#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */
+#endif
+
static int
arm_adjust_dyn (DSO *dso, int n, GElf_Dyn *dyn, GElf_Addr start,
GElf_Addr adjust)
@@ -151,6 +157,25 @@ arm_prelink_rel (struct prelink_info *info, GElf_Rel *rel, GElf_Addr reladdr)
return 0;
error (0, 0, "%s: R_ARM_COPY reloc in shared library?", dso->filename);
return 1;
+ case R_ARM_TLS_DTPOFF32:
+ write_le32 (dso, rel->r_offset, value);
+ break;
+ /* DTPMOD32 and TPOFF32 is impossible to predict in shared libraries
+ unless prelink sets the rules. */
+ case R_ARM_TLS_DTPMOD32:
+ if (dso->ehdr.e_type == ET_EXEC)
+ {
+ error (0, 0, "%s: R_ARM_TLS_DTPMOD32 reloc in executable?",
+ dso->filename);
+ return 1;
+ }
+ break;
+ case R_ARM_TLS_TPOFF32:
+ if (dso->ehdr.e_type == ET_EXEC)
+ error (0, 0, "%s: R_ARM_TLS_TPOFF32 relocs should not be present in "
+ "prelinked ET_EXEC REL sections",
+ dso->filename);
+ break;
default:
error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
(int) GELF_R_TYPE (rel->r_info));
@@ -201,6 +226,24 @@ arm_prelink_rela (struct prelink_info *info, GElf_Rela *rela,
return 0;
error (0, 0, "%s: R_ARM_COPY reloc in shared library?", dso->filename);
return 1;
+ case R_ARM_TLS_DTPOFF32:
+ write_le32 (dso, rela->r_offset, value + rela->r_addend);
+ break;
+ /* DTPMOD32 and TPOFF32 is impossible to predict in shared libraries
+ unless prelink sets the rules. */
+ case R_ARM_TLS_DTPMOD32:
+ if (dso->ehdr.e_type == ET_EXEC)
+ {
+ error (0, 0, "%s: R_ARM_TLS_DTPMOD32 reloc in executable?",
+ dso->filename);
+ return 1;
+ }
+ break;
+ case R_ARM_TLS_TPOFF32:
+ if (dso->ehdr.e_type == ET_EXEC && info->resolvetls)
+ write_le32 (dso, rela->r_offset,
+ value + rela->r_addend + info->resolvetls->offset);
+ break;
default:
error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
(int) GELF_R_TYPE (rela->r_info));
@@ -315,6 +358,7 @@ arm_prelink_conflict_rel (DSO *dso, struct prelink_info *info, GElf_Rel *rel,
{
GElf_Addr value;
struct prelink_conflict *conflict;
+ struct prelink_tls *tls;
GElf_Rela *ret;
if (GELF_R_TYPE (rel->r_info) == R_ARM_RELATIVE
@@ -324,8 +368,34 @@ arm_prelink_conflict_rel (DSO *dso, struct prelink_info *info, GElf_Rel *rel,
conflict = prelink_conflict (info, GELF_R_SYM (rel->r_info),
GELF_R_TYPE (rel->r_info));
if (conflict == NULL)
- return 0;
- value = conflict_lookup_value (conflict);
+ {
+ if (info->curtls == NULL)
+ return 0;
+
+ switch (GELF_R_TYPE (rel->r_info))
+ {
+ /* Even local DTPMOD and TPOFF relocs need conflicts. */
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_TPOFF32:
+ break;
+
+ default:
+ return 0;
+ }
+ value = 0;
+ }
+ else
+ {
+ /* DTPOFF32 wants to see only real conflicts, not lookups
+ with reloc_class RTYPE_CLASS_TLS. */
+ if (GELF_R_TYPE (rel->r_info) == R_ARM_TLS_DTPOFF32
+ && conflict->lookup.tls == conflict->conflict.tls
+ && conflict->lookupval == conflict->conflictval)
+ return 0;
+
+ value = conflict_lookup_value (conflict);
+ }
+
ret = prelink_conflict_add_rela (info);
if (ret == NULL)
return 1;
@@ -345,6 +415,33 @@ arm_prelink_conflict_rel (DSO *dso, struct prelink_info *info, GElf_Rel *rel,
case R_ARM_COPY:
error (0, 0, "R_ARM_COPY should not be present in shared libraries");
return 1;
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_DTPOFF32:
+ case R_ARM_TLS_TPOFF32:
+ if (conflict != NULL
+ && (conflict->reloc_class != RTYPE_CLASS_TLS
+ || conflict->lookup.tls == NULL))
+ {
+ error (0, 0, "%s: TLS reloc not resolving to STT_TLS symbol",
+ dso->filename);
+ return 1;
+ }
+ tls = conflict ? conflict->lookup.tls : info->curtls;
+ ret->r_info = GELF_R_INFO (0, R_ARM_ABS32);
+ switch (GELF_R_TYPE (rel->r_info))
+ {
+ case R_ARM_TLS_DTPMOD32:
+ ret->r_addend = tls->modid;
+ break;
+ case R_ARM_TLS_DTPOFF32:
+ ret->r_addend = value;
+ break;
+ case R_ARM_TLS_TPOFF32:
+ ret->r_addend = (value + read_ule32 (dso, rel->r_offset)
+ + tls->offset);
+ break;
+ }
+ break;
default:
error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
(int) GELF_R_TYPE (rel->r_info));
@@ -359,6 +456,7 @@ arm_prelink_conflict_rela (DSO *dso, struct prelink_info *info,
{
GElf_Addr value;
struct prelink_conflict *conflict;
+ struct prelink_tls *tls;
GElf_Rela *ret;
Elf32_Sword val;
@@ -368,8 +466,36 @@ arm_prelink_conflict_rela (DSO *dso, struct prelink_info *info,
return 0;
conflict = prelink_conflict (info, GELF_R_SYM (rela->r_info),
GELF_R_TYPE (rela->r_info));
+
if (conflict == NULL)
- return 0;
+ {
+ if (info->curtls == NULL)
+ return 0;
+
+ switch (GELF_R_TYPE (rela->r_info))
+ {
+ /* Even local DTPMOD and TPOFF relocs need conflicts. */
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_TPOFF32:
+ break;
+
+ default:
+ return 0;
+ }
+ value = 0;
+ }
+ else
+ {
+ /* DTPOFF32 wants to see only real conflicts, not lookups
+ with reloc_class RTYPE_CLASS_TLS. */
+ if (GELF_R_TYPE (rela->r_info) == R_ARM_TLS_DTPOFF32
+ && conflict->lookup.tls == conflict->conflict.tls
+ && conflict->lookupval == conflict->conflictval)
+ return 0;
+
+ value = conflict_lookup_value (conflict);
+ }
+
value = conflict_lookup_value (conflict);
ret = prelink_conflict_add_rela (info);
if (ret == NULL)
@@ -398,6 +524,32 @@ arm_prelink_conflict_rela (DSO *dso, struct prelink_info *info,
case R_ARM_COPY:
error (0, 0, "R_ARM_COPY should not be present in shared libraries");
return 1;
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_DTPOFF32:
+ case R_ARM_TLS_TPOFF32:
+ if (conflict != NULL
+ && (conflict->reloc_class != RTYPE_CLASS_TLS
+ || conflict->lookup.tls == NULL))
+ {
+ error (0, 0, "%s: TLS reloc not resolving to STT_TLS symbol",
+ dso->filename);
+ return 1;
+ }
+ tls = conflict ? conflict->lookup.tls : info->curtls;
+ ret->r_info = GELF_R_INFO (0, R_ARM_ABS32);
+ switch (GELF_R_TYPE (rela->r_info))
+ {
+ case R_ARM_TLS_DTPMOD32:
+ ret->r_addend = tls->modid;
+ break;
+ case R_ARM_TLS_DTPOFF32:
+ ret->r_addend = value;
+ break;
+ case R_ARM_TLS_TPOFF32:
+ ret->r_addend = value + rela->r_offset + tls->offset;
+ break;
+ }
+ break;
default:
error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
(int) GELF_R_TYPE (rela->r_info));
@@ -418,6 +570,7 @@ arm_rel_to_rela (DSO *dso, GElf_Rel *rel, GElf_Rela *rela)
abort ();
case R_ARM_RELATIVE:
case R_ARM_ABS32:
+ case R_ARM_TLS_TPOFF32:
rela->r_addend = (Elf32_Sword) read_ule32 (dso, rel->r_offset);
break;
case R_ARM_PC24:
@@ -426,6 +579,8 @@ arm_rel_to_rela (DSO *dso, GElf_Rel *rel, GElf_Rela *rela)
break;
case R_ARM_COPY:
case R_ARM_GLOB_DAT:
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_DTPOFF32:
rela->r_addend = 0;
break;
}
@@ -445,6 +600,7 @@ arm_rela_to_rel (DSO *dso, GElf_Rela *rela, GElf_Rel *rel)
abort ();
case R_ARM_RELATIVE:
case R_ARM_ABS32:
+ case R_ARM_TLS_TPOFF32:
write_le32 (dso, rela->r_offset, rela->r_addend);
break;
case R_ARM_PC24:
@@ -453,6 +609,8 @@ arm_rela_to_rel (DSO *dso, GElf_Rela *rela, GElf_Rel *rel)
| ((rela->r_addend >> 2) & 0xffffff));
break;
case R_ARM_GLOB_DAT:
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_DTPOFF32:
write_le32 (dso, rela->r_offset, 0);
break;
}
@@ -488,6 +646,14 @@ arm_need_rel_to_rela (DSO *dso, int first, int last)
/* FALLTHROUGH */
case R_ARM_PC24:
return 1;
+ case R_ARM_TLS_TPOFF32:
+ /* In shared libraries TPOFF is changed always into
+ conflicts, for executables we need to preserve
+ original addend. */
+ if (dso->ehdr.e_type == ET_EXEC)
+ return 1;
+
+ break;
}
}
}
@@ -612,6 +778,12 @@ arm_undo_prelink_rel (DSO *dso, GElf_Rel *rel, GElf_Addr reladdr)
return 0;
error (0, 0, "%s: R_ARM_COPY reloc in shared library?", dso->filename);
return 1;
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_DTPOFF32:
+ write_le32 (dso, rel->r_offset, 0);
+ break;
+ case R_ARM_TLS_TPOFF32:
+ break;
default:
error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
(int) GELF_R_TYPE (rel->r_info));
@@ -634,6 +806,10 @@ arm_reloc_class (int reloc_type)
{
case R_ARM_COPY: return RTYPE_CLASS_COPY;
case R_ARM_JUMP_SLOT: return RTYPE_CLASS_PLT;
+ case R_ARM_TLS_DTPMOD32:
+ case R_ARM_TLS_DTPOFF32:
+ case R_ARM_TLS_TPOFF32:
+ return RTYPE_CLASS_TLS;
default: return RTYPE_CLASS_VALID;
}
}
@@ -647,6 +823,7 @@ PL_ARCH = {
.R_COPY = R_ARM_COPY,
.R_RELATIVE = R_ARM_RELATIVE,
.dynamic_linker = "/lib/ld-linux.so.2",
+ .dynamic_linker_alt = "/lib/ld-linux.so.3",
.adjust_dyn = arm_adjust_dyn,
.adjust_rel = arm_adjust_rel,
.adjust_rela = arm_adjust_rela,
diff --git a/src/dso.c b/src/dso.c
index b55d027..50443af 100644
--- a/src/dso.c
+++ b/src/dso.c
@@ -1026,7 +1026,9 @@ adjust_symtab (DSO *dso, int n, GElf_Addr start, GElf_Addr adjust)
{
gelfx_getsym (dso->elf, data, ndx, &sym);
if (sym.st_shndx == SHN_ABS && sym.st_value != 0
- && GELF_ST_TYPE (sym.st_info) <= STT_FUNC)
+ && (GELF_ST_TYPE (sym.st_info) <= STT_FUNC
+ || (dso->ehdr.e_machine == EM_ARM
+ && GELF_ST_TYPE (sym.st_info) == STT_ARM_TFUNC)))
{
/* This is problematic. How do we find out if
we should relocate this? Assume we should. */
diff --git a/src/get.c b/src/get.c
index 2da6fc4..6f0a016 100644
--- a/src/get.c
+++ b/src/get.c
@@ -30,6 +30,7 @@ int
is_ldso_soname (const char *soname)
{
if (! strcmp (soname, "ld-linux.so.2")
+ || ! strcmp (soname, "ld-linux.so.3")
|| ! strcmp (soname, "ld.so.1")
|| ! strcmp (soname, "ld-linux-ia64.so.2")
|| ! strcmp (soname, "ld-linux-x86-64.so.2")