Skip to contentSkip to conversation

Let gen-vdso tool to use internal ELF header

PATCH In review Jim Shu 2 participants 7 messages Jul 26, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Jim Shu

author
#0 lore raw

cover Let gen-vdso tool to use internal ELF header

Let gen-vdso tool to use QEMU's internal ELF header. It could avoid compatibility issue of glibc version in the environment. QEMU RISC-V zicfiss/lp extension patchset will add "EM_RISCV" symbol to it. This symbol is not supported in the legacy glibc.

Jim Shu (2):
include/elf.h: align ELF macro name with glibc
linux-user: Add QEMU include path to vdso

 include/elf.h          | 2 +-
 linux-user/meson.build | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 include/elf.h: align ELF macro name with glibc

Rename DT_BINDNOW to DT_BIND_NOW to align with glibc header: "elf/elf.h"

---
 include/elf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/elf.h +1 -1
index e7259ec366..ef47b5e2ad 100644
@@ -235,7 +235,7 @@ typedef struct mips_elf_abiflags_v0 {
 #define DT_DEBUG        21
 #define DT_TEXTREL      22
 #define DT_JMPREL       23
-#define DT_BINDNOW      24
+#define DT_BIND_NOW     24
 #define DT_INIT_ARRAY   25
 #define DT_FINI_ARRAY   26
 #define DT_INIT_ARRAYSZ 27
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 2/2 linux-user: Add QEMU include path to vdso

In reply to Jim Shu

Add include path to 'gen-vdso.c' to get ELF header in QEMU source.

---
 linux-user/meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
linux-user/meson.build +4 -1
index bc41e8c3bc..ccce4f7e70 100644
@@ -30,8 +30,11 @@ linux_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', if_true: files('sem
 
 syscall_nr_generators = {}
 
+# It requires "include/elf.h"
+gen_vdso_inc = include_directories('..' / 'include')
 gen_vdso_exe = executable('gen-vdso', 'gen-vdso.c',
-                          native: true, build_by_default: false)
+                          native: true, build_by_default: false,
+                          include_directories: gen_vdso_inc)
 gen_vdso = generator(gen_vdso_exe, output: '@[email protected]',
                      arguments: ['-o', '@OUTPUT@', '@EXTRA_ARGS@', '@INPUT@'])
 
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 2/2] linux-user: Add QEMU include path to vdso

Quoted 14 lines · Jim Shu

Add include path to 'gen-vdso.c' to get ELF header in QEMU source.

---
  linux-user/meson.build | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
linux-user/meson.build +0 -0
index bc41e8c3bc..ccce4f7e70 100644
@@ -30,8 +30,11 @@ linux_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', if_true: files('sem
 
  syscall_nr_generators = {}

linux-user/meson.build linux_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING', if_true: files('sem · line 40

Quoted 10 lines
linux-user/meson.build +4 -1
 
+# It requires "include/elf.h"
+gen_vdso_inc = include_directories('..' / 'include')
  gen_vdso_exe = executable('gen-vdso', 'gen-vdso.c',
-                          native: true, build_by_default: false)
+                          native: true, build_by_default: false,
+                          include_directories: gen_vdso_inc)
  gen_vdso = generator(gen_vdso_exe, output: '@[email protected]',
                       arguments: ['-o', '@OUTPUT@', '@EXTRA_ARGS@', '@INPUT@'])
 

Ok, I guess. I'm not convinced we need this. I tend to think our elf.h is way out of date, and perhaps should be removed. I suspect we only carry it around now for windows hosts, compiling the system loaders.

r~

#5 lore raw
In reply to Jim Shu
Quoted 4 lines · Jim Shu

Let gen-vdso tool to use QEMU's internal ELF header. It could avoid compatibility issue of glibc version in the environment. QEMU RISC-V zicfiss/lp extension patchset will add "EM_RISCV" symbol to it. This symbol is not supported in the legacy glibc.

I see EM_RISCV added added (by myself, amusingly, as part of a bulk merge) in 2016, included in glibc 2.24.

From repology, vs our oldest supported OS,

centos stream 8:   2.28
debian 11:         2.31
fedora 39:         2.37
opensuse leap 15:  2.28
ubuntu 20.04:      2.31

So unless there's some *other* symbol you require, all supported OS will have EM_RISCV.

r~

author
#6 lore raw

Hi Richard,

Thanks for your feedback.
I think it is reasonable. I will drop this patchset.

Regards,
Jim Shu

Quoted 22 lines · Richard Henderson
Quoted 4 lines · Jim Shu

Let gen-vdso tool to use QEMU's internal ELF header. It could avoid compatibility issue of glibc version in the environment. QEMU RISC-V zicfiss/lp extension patchset will add "EM_RISCV" symbol to it. This symbol is not supported in the legacy glibc.

I see EM_RISCV added added (by myself, amusingly, as part of a bulk merge) in 2016, included in glibc 2.24.

From repology, vs our oldest supported OS,

centos stream 8:   2.28
debian 11:         2.31
fedora 39:         2.37
opensuse leap 15:  2.28
ubuntu 20.04:      2.31

So unless there's some *other* symbol you require, all supported OS will have EM_RISCV.

r~