1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

elf: Initialize GLRO (dl_read_only_area) after static dlopen (bug 33139)

The _dl_read_only_area function in the uninitialized ld.so after
static dlopen is not able to find anything.  Instead, we need to
redirect to the code from the statically linked main program.

Fixes commit d60fffe28a46b2a41fc308c1804ff02375d27408 ("debug:
Improve '%n' fortify detection (BZ 30932)").

Reviewed-by: Adhemerval Zanella Netto  <adhemerval.zanella@linaro.org>
This commit is contained in:
Florian Weimer
2025-07-18 19:58:59 +02:00
parent 3a9c1497e3
commit 01196393c2
4 changed files with 15 additions and 1 deletions

View File

@@ -184,12 +184,19 @@ CPPFLAGS-tst-chk-cancel.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-tst-sprintf-fortify-rdonly.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-tst-sprintf-fortify-rdonly-mod.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-tst-sprintf-fortify-rdonly-dlopen.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-tst-sprintf-fortify-rdonly-static.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-tst-fortify-syslog.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-tst-fortify-wide.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
$(objpfx)tst-sprintf-fortify-rdonly: $(objpfx)tst-sprintf-fortify-rdonly-mod.so
$(objpfx)tst-sprintf-fortify-rdonly.out: \
$(objpfx)tst-sprintf-fortify-rdonly-dlopen.so
$(objpfx)tst-sprintf-fortify-rdonly-static: \
$(objpfx)tst-sprintf-fortify-rdonly-dlopen.o
$(objpfx)tst-sprintf-fortify-rdonly-static.out: \
$(objpfx)tst-sprintf-fortify-rdonly-dlopen.so
tst-sprintf-fortify-rdonly-static-ENV = \
LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)/elf
# _FORTIFY_SOURCE tests.
# Auto-generate tests for _FORTIFY_SOURCE for different levels, compilers and
@@ -328,9 +335,14 @@ tests = \
tst-longjmp_chk3 \
tst-realpath-chk \
tst-sprintf-fortify-rdonly \
tst-sprintf-fortify-rdonly-static \
tst-sprintf-fortify-unchecked \
# tests
tests-static = \
tst-sprintf-fortify-rdonly-static \
# tests-static
tests-time64 += \
$(tests-all-time64-chk) \
# tests-time64

View File

@@ -0,0 +1 @@
#include "tst-sprintf-fortify-rdonly.c"