[RFC,01/19] Inhibit early libcalls before ifunc support is ready

Message ID 20230207001618.458947-2-christoph.muellner@vrull.eu
State New
Series riscv: ifunc support with optimized mem*/str*/cpu_relax routines |


Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Christoph Müllner Feb. 7, 2023, 12:16 a.m. UTC
  From: Christoph Müllner <christoph.muellner@vrull.eu>

One of the few tasks in __libc_start_main_impl, before
ifunc support is ready on many architectures is to process
the AUX vector. GCC is able to detect libcall routines in
this code, which will result in invocations of uninitialized
ifunc pointers.

Let's set the proper attributes to these early functions
to avoid avoid libcalls.

This was observed to be an issue (endless loop) in combination with:
- GCC upstream/master
- glibc upstream/master
- glibc built with -O3
- target arch RISC-V (RV64)
- experimental RISC-V ifunc support patches
Other combinations/architectures might be affected as well.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
 csu/libc-start.c | 1 +
 elf/dl-support.c | 1 +
 2 files changed, 2 insertions(+)


diff --git a/csu/libc-start.c b/csu/libc-start.c
index c3bb6d09bc..8566a54df5 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -231,6 +231,7 @@  STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
    locate constructors and destructors.  For statically linked
    executables, the relevant symbols are access directly.  */
 LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
 		 int argc, char **argv,
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 9714f75db0..b0e9e1636a 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -242,6 +242,7 @@  __rtld_lock_define_initialized_recursive (, _dl_load_tls_lock)
 int _dl_clktck;
 _dl_aux_init (ElfW(auxv_t) *av)