git: dd4155bec744 - main - rtld: Add arch_digest_dynamic

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Fri, 17 May 2024 10:21:50 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=dd4155bec744acf2ebfd037f7719c4aed9283a73

commit dd4155bec744acf2ebfd037f7719c4aed9283a73
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-05-07 16:14:47 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-05-17 09:37:12 +0000

    rtld: Add arch_digest_dynamic
    
    This will be used to handle the DT_AARCH64_VARIANT_PCS tag.
    
    Reviewed by:    kib
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D45117
---
 libexec/rtld-elf/aarch64/rtld_machdep.h   | 3 +++
 libexec/rtld-elf/amd64/rtld_machdep.h     | 3 +++
 libexec/rtld-elf/arm/rtld_machdep.h       | 3 +++
 libexec/rtld-elf/i386/rtld_machdep.h      | 3 +++
 libexec/rtld-elf/powerpc/rtld_machdep.h   | 3 +++
 libexec/rtld-elf/powerpc64/rtld_machdep.h | 3 +++
 libexec/rtld-elf/riscv/rtld_machdep.h     | 3 +++
 libexec/rtld-elf/rtld.c                   | 3 +++
 8 files changed, 24 insertions(+)

diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h
index a3031fe7e539..347ef5f381fe 100644
--- a/libexec/rtld-elf/aarch64/rtld_machdep.h
+++ b/libexec/rtld-elf/aarch64/rtld_machdep.h
@@ -47,6 +47,9 @@ struct Struct_Obj_Entry;
 	(const Elf_Dyn *)_dynamic_addr;					\
 })
 
+/* No arch-specific dynamic tags */
+#define	arch_digest_dynamic(obj, dynp)	false
+
 bool arch_digest_note(struct Struct_Obj_Entry *obj, const Elf_Note *note);
 
 Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h
index 558c0a73123f..1797d13c847d 100644
--- a/libexec/rtld-elf/amd64/rtld_machdep.h
+++ b/libexec/rtld-elf/amd64/rtld_machdep.h
@@ -41,6 +41,9 @@ struct Struct_Obj_Entry;
 Elf_Dyn *rtld_dynamic_addr(void);
 #define	rtld_dynamic(obj)	rtld_dynamic_addr()
 
+/* No arch-specific dynamic tags */
+#define	arch_digest_dynamic(obj, dynp)	false
+
 /* No architecture specific notes */
 #define	arch_digest_note(obj, note)	false
 
diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h
index a492ac0eab77..f59b30028a3b 100644
--- a/libexec/rtld-elf/arm/rtld_machdep.h
+++ b/libexec/rtld-elf/arm/rtld_machdep.h
@@ -41,6 +41,9 @@ struct Struct_Obj_Entry;
 /* 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
+
 /* No architecture specific notes */
 #define	arch_digest_note(obj, note)	false
 
diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h
index f39300d16ddb..581f1dfb002d 100644
--- a/libexec/rtld-elf/i386/rtld_machdep.h
+++ b/libexec/rtld-elf/i386/rtld_machdep.h
@@ -41,6 +41,9 @@ struct Struct_Obj_Entry;
 #define rtld_dynamic(obj) \
     ((const Elf_Dyn *)((obj)->relocbase + (Elf_Addr)&_DYNAMIC))
 
+/* No arch-specific dynamic tags */
+#define	arch_digest_dynamic(obj, dynp)	false
+
 /* No architecture specific notes */
 #define	arch_digest_note(obj, note)	false
 
diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h
index 03ef11f4034b..69fc52369201 100644
--- a/libexec/rtld-elf/powerpc/rtld_machdep.h
+++ b/libexec/rtld-elf/powerpc/rtld_machdep.h
@@ -40,6 +40,9 @@ struct Struct_Obj_Entry;
 /* 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
+
 /* No architecture specific notes */
 #define	arch_digest_note(obj, note)	false
 
diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h
index f36be944e80a..d1dab63d3779 100644
--- a/libexec/rtld-elf/powerpc64/rtld_machdep.h
+++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h
@@ -40,6 +40,9 @@ struct Struct_Obj_Entry;
 /* 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
+
 /* No architecture specific notes */
 #define	arch_digest_note(obj, note)	false
 
diff --git a/libexec/rtld-elf/riscv/rtld_machdep.h b/libexec/rtld-elf/riscv/rtld_machdep.h
index 2244a424f8c1..fb5f5643efc6 100644
--- a/libexec/rtld-elf/riscv/rtld_machdep.h
+++ b/libexec/rtld-elf/riscv/rtld_machdep.h
@@ -54,6 +54,9 @@ uint64_t set_gp(struct Struct_Obj_Entry *obj);
 	(const Elf_Dyn *)_dynamic_addr;                                 \
 })
 
+/* No arch-specific dynamic tags */
+#define	arch_digest_dynamic(obj, dynp)	false
+
 /* No architecture specific notes */
 #define	arch_digest_note(obj, note)	false
 
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 5743bbdd6f61..20c340ed15a3 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -1554,6 +1554,9 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
 	    break;
 
 	default:
+	    if (arch_digest_dynamic(obj, dynp))
+		break;
+
 	    if (!early) {
 		dbg("Ignoring d_tag %ld = %#lx", (long)dynp->d_tag,
 		    (long)dynp->d_tag);