rtld: Move powerpc specific code to powerpc files

There are two variables set by dynamic tags in the powerpc runtime
linker. Now we have a way to split out architecture-specific dynamic
tags use it to handle these.

Reviewed by:	kib, jhibbits
Obtained from:	jhibbits (earlier version)
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45182
This commit is contained in:
Andrew Turner 2024-05-13 19:13:07 +01:00
parent 9e48c30e25
commit 1cd90a2c16
6 changed files with 28 additions and 25 deletions

View file

@ -57,6 +57,17 @@
void _rtld_bind_secureplt_start(void);
bool
arch_digest_dynamic(struct Struct_Obj_Entry *obj, const Elf_Dyn *dynp)
{
if (dynp->d_tag == DT_PPC_GOT) {
obj->gotptr = (Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
return (true);
}
return (false);
}
/*
* Process the R_PPC_COPY relocations
*/

View file

@ -35,13 +35,13 @@
struct Struct_Obj_Entry;
#define MD_OBJ_ENTRY
#define MD_OBJ_ENTRY \
Elf_Addr *gotptr; /* GOT pointer (secure-plt only) */
/* Return the address of the .dynamic section in the dynamic linker. */
#define rtld_dynamic(obj) (&_DYNAMIC)
/* No arch-specific dynamic tags */
#define arch_digest_dynamic(obj, dynp) false
bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *);
/* No architecture specific notes */
#define arch_digest_note(obj, note) false

View file

@ -52,6 +52,17 @@ struct funcdesc {
};
#endif
bool
arch_digest_dynamic(struct Struct_Obj_Entry *obj, const Elf_Dyn *dynp)
{
if (dynp->d_tag == DT_PPC64_GLINK) {
obj->glink = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
return (true);
}
return (false);
}
/*
* Process the R_PPC_COPY relocations
*/

View file

@ -35,13 +35,13 @@
struct Struct_Obj_Entry;
#define MD_OBJ_ENTRY
#define MD_OBJ_ENTRY \
Elf_Addr glink; /* GLINK PLT call stub section */
/* Return the address of the .dynamic section in the dynamic linker. */
#define rtld_dynamic(obj) (&_DYNAMIC)
/* No arch-specific dynamic tags */
#define arch_digest_dynamic(obj, dynp) false
bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *);
/* No architecture specific notes */
#define arch_digest_note(obj, note) false

View file

@ -1520,18 +1520,6 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
obj->static_tls = true;
break;
#ifdef __powerpc__
#ifdef __powerpc64__
case DT_PPC64_GLINK:
obj->glink = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
#else
case DT_PPC_GOT:
obj->gotptr = (Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
break;
#endif
#endif
case DT_FLAGS_1:
if (dynp->d_un.d_val & DF_1_NOOPEN)
obj->z_noopen = true;

View file

@ -183,13 +183,6 @@ typedef struct Struct_Obj_Entry {
const Elf_Sym *symtab; /* Symbol table */
const char *strtab; /* String table */
unsigned long strsize; /* Size in bytes of string table */
#ifdef __powerpc__
#ifdef __powerpc64__
Elf_Addr glink; /* GLINK PLT call stub section */
#else
Elf_Addr *gotptr; /* GOT pointer (secure-plt only) */
#endif
#endif
const Elf_Verneed *verneed; /* Required versions. */
Elf_Word verneednum; /* Number of entries in verneed table */