diff options
Diffstat (limited to 'elf/Makefile')
-rw-r--r-- | elf/Makefile | 426 |
1 files changed, 395 insertions, 31 deletions
diff --git a/elf/Makefile b/elf/Makefile index 0792b57..3a5596e 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2024 Free Software Foundation, Inc. +# Copyright (C) 1995-2025 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -34,7 +34,6 @@ routines = \ dl-addr \ dl-addr-obj \ dl-early_allocate \ - dl-find_object \ dl-iteratephdr \ dl-libc \ dl-origin \ @@ -58,9 +57,12 @@ dl-routines = \ dl-close \ dl-debug \ dl-debug-symbols \ + dl-debug_state \ dl-deps \ dl-exception \ dl-execstack \ + dl-execstack-tunable \ + dl-find_object \ dl-fini \ dl-init \ dl-load \ @@ -72,6 +74,7 @@ dl-routines = \ dl-open \ dl-origin \ dl-printf \ + dl-readonly-area \ dl-reloc \ dl-runtime \ dl-scope \ @@ -266,6 +269,7 @@ tests-static-normal := \ tst-array1-static \ tst-array5-static \ tst-dl-iter-static \ + tst-dlopen-sgid \ tst-dst-static \ tst-env-setuid-static \ tst-getauxval-static \ @@ -322,6 +326,7 @@ tests := \ tests-internal := \ $(tests-static-internal) \ tst-tls1 \ + tst-tls_tp_offset \ # tests-internal tests-static := $(tests-static-normal) $(tests-static-internal) @@ -378,6 +383,7 @@ tests += \ tst-align3 \ tst-audit-tlsdesc \ tst-audit-tlsdesc-dlopen \ + tst-audit-tlsdesc-dlopen2 \ tst-audit1 \ tst-audit2 \ tst-audit8 \ @@ -414,6 +420,10 @@ tests += \ tst-dlmopen1 \ tst-dlmopen3 \ tst-dlmopen4 \ + tst-dlmopen4-nonpic \ + tst-dlmopen4-pic \ + tst-dlopen-auditdup \ + tst-dlopen-constructor-null \ tst-dlopen-self \ tst-dlopen-tlsmodid \ tst-dlopen-tlsreinit1 \ @@ -432,6 +442,12 @@ tests += \ tst-global1 \ tst-global2 \ tst-gnu2-tls2 \ + tst-hash-collision1 \ + tst-hash-collision1-gnu \ + tst-hash-collision1-sysv \ + tst-hash-collision2 \ + tst-hash-collision2-gnu \ + tst-hash-collision2-sysv \ tst-initfinilazyfail \ tst-initorder \ tst-initorder2 \ @@ -446,17 +462,22 @@ tests += \ tst-noload \ tst-non-directory-path \ tst-null-argv \ + tst-origin \ tst-p_align1 \ tst-p_align2 \ tst-p_align3 \ tst-recursive-tls \ tst-relsort1 \ tst-ro-dynamic \ + tst-rtld-no-malloc \ + tst-rtld-no-malloc-audit \ + tst-rtld-no-malloc-preload \ tst-rtld-run-static \ tst-single_threaded \ tst-single_threaded-pthread \ tst-sonamemove-dlopen \ tst-sonamemove-link \ + tst-startup-errno \ tst-thrlock \ tst-tls-dlinfo \ tst-tls-ie \ @@ -476,6 +497,9 @@ tests += \ tst-tls19 \ tst-tls20 \ tst-tls21 \ + tst-tls22 \ + tst-tls22-gnu2 \ + tst-tls23 \ tst-tlsalign \ tst-tlsalign-extern \ tst-tlsgap \ @@ -483,6 +507,7 @@ tests += \ tst-unique2 \ tst-unwind-ctor \ tst-unwind-main \ + tst-version-hash-zero \ unload3 \ unload4 \ unload5 \ @@ -492,11 +517,15 @@ tests += \ valgrind-test \ # tests tests-cxx = \ - tst-dlopen-nodelete-reloc \ tst-nodelete \ tst-unique3 \ tst-unique4 \ # tests-cxx +ifeq ($(have-test-stb-gnu-unique), yes) +tests-cxx += \ + tst-dlopen-nodelete-reloc \ + # tests-cxx +endif tests += $(if $(CXX),$(tests-cxx)) @@ -513,6 +542,9 @@ tests-internal += \ tst-dl_find_object \ tst-dl_find_object-threads \ tst-dlmopen2 \ + tst-hash-collision3 \ + tst-link-map-contiguous-ldso \ + tst-link-map-contiguous-libc \ tst-ptrguard1 \ tst-stackguard1 \ tst-tls-surplus \ @@ -524,6 +556,10 @@ tests-internal += \ unload2 \ # tests-internal +ifeq ($(build-hardcoded-path-in-tests),yes) +tests-internal += tst-link-map-contiguous-main +endif + tests-container += \ tst-dlopen-self-container \ tst-dlopen-tlsmodid-container \ @@ -543,11 +579,25 @@ endif selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null) ifneq ($(selinux-enabled),1) +ifeq ($(have-test-cc-trampoline),yes) tests-execstack-yes = \ tst-execstack \ tst-execstack-needed \ tst-execstack-prog \ + tst-execstack-tunable \ # tests-execstack-yes +tests-execstack-static-yes = \ + tst-execstack-prog-static \ + tst-execstack-prog-static-tunable \ + # tests-execstack-static-yes +ifeq (yes,$(run-built-tests)) +tests-execstack-special-yes = \ + $(objpfx)tst-execstack-needed-noexecstack.out \ + $(objpfx)tst-execstack-prog-noexecstack.out \ + $(objpfx)tst-execstack-prog-static-noexecstack.out \ + # tests-execstack-special-yes +endif # $(run-built-tests) +endif endif ifeq ($(have-depaudit),yes) tests += \ @@ -642,6 +692,8 @@ $(objpfx)tst-rtld-dash-dash.out: tst-rtld-dash-dash.sh $(objpfx)ld.so $(evaluate-test) tests += $(tests-execstack-$(have-z-execstack)) +tests-static+= $(tests-execstack-static-$(have-z-execstack)) +tests-special += $(tests-execstack-special-$(have-z-execstack)) ifeq ($(run-built-tests),yes) tests-special += \ $(objpfx)tst-ldconfig-X.out \ @@ -676,9 +728,15 @@ tst-tls-many-dynamic-modules-dep-bad = \ extra-test-objs += \ $(tlsmod17a-modules:=.os) \ $(tlsmod18a-modules:=.os) \ + tst-tls22-mod1-vars.os \ + tst-tls22-mod2-vars.os \ + tst-tls22-vars.o \ tst-tlsalign-vars.o \ # extra-test-objs test-extras += \ + tst-tls22-mod1-vars \ + tst-tls22-mod2-vars \ + tst-tls22-vars \ tst-tlsalign-vars \ tst-tlsmod17a \ tst-tlsmod18a \ @@ -721,6 +779,13 @@ modules-names += \ libmarkermod5-3 \ libmarkermod5-4 \ libmarkermod5-5 \ + libmarkermod6-1 \ + libmarkermod6-2 \ + libmarkermod6-3 \ + libmarkermod6-4 \ + libmarkermod6-5 \ + libmarkermod6-6 \ + liborigin-mod \ libtracemod1-1 \ libtracemod2-1 \ libtracemod3-1 \ @@ -824,6 +889,7 @@ modules-names += \ tst-auditmanymod8 \ tst-auditmanymod9 \ tst-auditmod-tlsdesc \ + tst-auditmod-tlsdesc2 \ tst-auditmod1 \ tst-auditmod11 \ tst-auditmod12 \ @@ -864,6 +930,11 @@ modules-names += \ tst-dlmopen-twice-mod1 \ tst-dlmopen-twice-mod2 \ tst-dlmopen1mod \ + tst-dlopen-auditdup-auditmod \ + tst-dlopen-auditdupmod \ + tst-dlopen-constructor-null-mod1 \ + tst-dlopen-constructor-null-mod2 \ + tst-dlopen-sgid-mod \ tst-dlopen-tlsreinitmod1 \ tst-dlopen-tlsreinitmod2 \ tst-dlopen-tlsreinitmod3 \ @@ -881,6 +952,16 @@ modules-names += \ tst-gnu2-tls2mod0 \ tst-gnu2-tls2mod1 \ tst-gnu2-tls2mod2 \ + tst-hash-collision1-mod \ + tst-hash-collision1-mod-gnu \ + tst-hash-collision1-mod-sysv \ + tst-hash-collision2-mod1 \ + tst-hash-collision2-mod1-gnu \ + tst-hash-collision2-mod1-sysv \ + tst-hash-collision2-mod2 \ + tst-hash-collision2-mod2-gnu \ + tst-hash-collision2-mod2-sysv \ + tst-hash-collision3-mod \ tst-initlazyfailmod \ tst-initorder2a \ tst-initorder2b \ @@ -948,6 +1029,11 @@ modules-names += \ tst-tls19mod3 \ tst-tls20mod-bad \ tst-tls21mod \ + tst-tls22-mod1 \ + tst-tls22-mod1-gnu2 \ + tst-tls22-mod2 \ + tst-tls22-mod2-gnu2 \ + tst-tls23-mod \ tst-tlsalign-lib \ tst-tlsgap-mod0 \ tst-tlsgap-mod1 \ @@ -978,6 +1064,9 @@ modules-names += \ tst-unique2mod1 \ tst-unique2mod2 \ tst-unwind-ctor-lib \ + tst-version-hash-zero-linkmod \ + tst-version-hash-zero-mod \ + tst-version-hash-zero-refmod \ unload2dep \ unload2mod \ unload3mod1 \ @@ -1004,6 +1093,15 @@ modules-names += \ # modules-names modules-names-cxx = \ + tst-nodelete-rtldmod \ + tst-nodelete-uniquemod \ + tst-nodelete-zmod \ + tst-unique3lib \ + tst-unique3lib2 \ + tst-unique4lib \ + # modules-names-cxx +ifeq ($(have-test-stb-gnu-unique), yes) +modules-names-cxx += \ tst-dlopen-nodelete-reloc-mod1 \ tst-dlopen-nodelete-reloc-mod2 \ tst-dlopen-nodelete-reloc-mod3 \ @@ -1021,13 +1119,8 @@ modules-names-cxx = \ tst-dlopen-nodelete-reloc-mod15 \ tst-dlopen-nodelete-reloc-mod16 \ tst-dlopen-nodelete-reloc-mod17 \ - tst-nodelete-rtldmod \ - tst-nodelete-uniquemod \ - tst-nodelete-zmod \ - tst-unique3lib \ - tst-unique3lib2 \ - tst-unique4lib \ # modules-names-cxx +endif modules-names += \ $(if $(CXX),$(modules-names-cxx)) \ @@ -1041,19 +1134,20 @@ modules-names += \ # Most modules build with _ISOMAC defined, but those filtered out # depend on internal headers. -modules-names-tests = $(filter-out ifuncmod% tst-tlsmod%,\ +modules-names-tests = $(filter-out ifuncmod% tst-tlsmod% \ + tst-hash-collision3-mod,\ $(modules-names)) # For +depfiles in Makerules. extra-test-objs += tst-auditmod17.os -ifneq (no,$(have-mtls-descriptor)) +ifneq (no,$(have-test-mtls-descriptor)) tests += tst-gnu2-tls1 modules-names += tst-gnu2-tls1mod $(objpfx)tst-gnu2-tls1: $(objpfx)tst-gnu2-tls1mod.so tst-gnu2-tls1mod.so-no-z-defs = yes -CFLAGS-tst-gnu2-tls1mod.c += -mtls-dialect=$(have-mtls-descriptor) -endif # $(have-mtls-descriptor) +CFLAGS-tst-gnu2-tls1mod.c += -mtls-dialect=$(have-test-mtls-descriptor) +endif # $(have-test-mtls-descriptor) ifeq (yes,$(have-protected-data)) modules-names += tst-protected1moda tst-protected1modb @@ -1084,13 +1178,42 @@ tests-pie += \ tst-pie1 \ tst-pie2 \ # tests-pie +ifeq (yes,$(aligned-65536)) +tests += tst-pie-bss +tests-pie += tst-pie-bss +endif +ifneq (,$(load-address-ldflag)) +tests += \ + tst-pie-address \ + # tests +tests-pie += \ + tst-pie-address \ + # tests-pie +LDFLAGS-tst-pie-address += $(load-address-ldflag)=$(pde-load-address) +ifeq (yes,$(enable-static-pie)) +tests += \ + tst-pie-address-static \ + # tests +tests-static += \ + tst-pie-address-static \ + # tests-static +ifeq (yes,$(aligned-65536)) +tests += tst-pie-bss-static +tests-static += tst-pie-bss-static +endif +LDFLAGS-tst-pie-address-static += \ + $(load-address-ldflag)=$(pde-load-address) +endif +endif ifeq (yes,$(have-protected-data)) tests += vismain tests-pie += vismain CFLAGS-vismain.c += $(PIE-ccflag) endif endif +ifeq ($(have-test-cc-trampoline),yes) modules-execstack-yes = tst-execstack-mod +endif extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) # filtmod1.so, tst-big-note-lib.so, tst-ro-dynamic-mod.so have special @@ -1255,15 +1378,39 @@ $(objpfx)$(1).generated-makefile: $(1) mv $$@T $$@ -include $(objpfx)$(1).generated-makefile endef +# Likewise, where the .def file itself is generated. +define include_dsosort_tests_objpfx +$(objpfx)$(1).generated-makefile: $(objpfx)$(1) + $(PYTHON) $(..)scripts/dso-ordering-test.py \ + --description-file $$< --objpfx $(objpfx) --output-makefile $$@T + mv $$@T $$@ +-include $(objpfx)$(1).generated-makefile +endef endif -postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \ - $(objpfx)/dso-sort-tests-2.generated-makefile +postclean-generated += $(objpfx)dso-sort-tests-1.generated-makefile \ + $(objpfx)dso-sort-tests-2.generated-makefile \ + $(objpfx)dso-sort-tests-all2.generated-makefile \ + $(objpfx)dso-sort-tests-all3.generated-makefile \ + $(objpfx)dso-sort-tests-all4.generated-makefile # Generate from each testcase description file $(eval $(call include_dsosort_tests,dso-sort-tests-1.def)) $(eval $(call include_dsosort_tests,dso-sort-tests-2.def)) +$(objpfx)dso-sort-tests-all2.def: dso-sort-tests-all.py + $(PYTHON) $< 2 > $@ + +$(objpfx)dso-sort-tests-all3.def: dso-sort-tests-all.py + $(PYTHON) $< 3 > $@ + +$(objpfx)dso-sort-tests-all4.def: dso-sort-tests-all.py + $(PYTHON) $< 4 > $@ + +$(eval $(call include_dsosort_tests_objpfx,dso-sort-tests-all2.def)) +$(eval $(call include_dsosort_tests_objpfx,dso-sort-tests-all3.def)) +$(eval $(call include_dsosort_tests_objpfx,dso-sort-tests-all4.def)) + # BZ15311 is intentionally underlinked. LDFLAGS-tst-bz15311-b.so += -Wl,-z,lazy LDFLAGS-tst-bz15311-c.so += -Wl,-z,lazy @@ -1299,6 +1446,10 @@ $(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag) endif +ifeq ($(run-built-tests),yes) +tests-special += $(objpfx)tst-origin.out +endif + include ../Rules ifeq (yes,$(build-shared)) @@ -1328,11 +1479,8 @@ $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os) # discovery mechanism is not compatible with the libc implementation # when compiled for libc. rtld-stubbed-symbols = \ - __GI___pthread_disable_asynccancel \ - __GI___pthread_enable_asynccancel \ __libc_assert_fail \ - __pthread_disable_asynccancel \ - __pthread_enable_asynccancel \ + __syscall_cancel \ calloc \ free \ malloc \ @@ -1886,6 +2034,9 @@ $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so CPPFLAGS-tst-execstack.c += -DUSE_PTHREADS=0 LDFLAGS-tst-execstack = -Wl,-z,noexecstack LDFLAGS-tst-execstack-mod.so = -Wl,-z,execstack +ifeq ($(have-no-error-execstack),yes) +LDFLAGS-tst-execstack-mod.so += -Wl,--no-error-execstack +endif $(objpfx)tst-execstack-needed: $(objpfx)tst-execstack-mod.so LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack @@ -1893,6 +2044,56 @@ LDFLAGS-tst-execstack-needed = -Wl,-z,noexecstack LDFLAGS-tst-execstack-prog = -Wl,-z,execstack CFLAGS-tst-execstack-prog.c += -Wno-trampolines CFLAGS-tst-execstack-mod.c += -Wno-trampolines + +# It expects loading a module with executable stack to work. +CFLAGS-tst-execstack-tunable.c += -DUSE_PTHREADS=0 -DDEFAULT_RWX_STACK=1 +$(objpfx)tst-execstack-tunable.out: $(objpfx)tst-execstack-mod.so +tst-execstack-tunable-ENV = GLIBC_TUNABLES=glibc.rtld.execstack=2 + +LDFLAGS-tst-execstack-prog-static-tunable = -Wl,-z,noexecstack +tst-execstack-prog-static-tunable-ENV = GLIBC_TUNABLES=glibc.rtld.execstack=2 + +LDFLAGS-tst-execstack-prog-static = -Wl,-z,execstack +ifeq ($(have-no-error-execstack),yes) +LDFLAGS-tst-execstack-prog-static += -Wl,--no-error-execstack +endif +CFLAGS-tst-execstack-prog-static.c += -Wno-trampolines + +ifeq (yes,$(build-hardcoded-path-in-tests)) +tst-execstack-prog-noexecstack-msg = "Fatal glibc error: executable stack is not allowed$$" +else +tst-execstack-prog-noexecstack-msg = "error while loading shared libraries:.*cannot enable executable stack as shared object requires:" +endif + +$(objpfx)tst-execstack-prog-noexecstack.out: $(objpfx)tst-execstack-prog + $(test-program-cmd-before-env) \ + $(run-program-env) \ + GLIBC_TUNABLES=glibc.rtld.execstack=0 \ + $(test-program-cmd-after-env) $< \ + > $@ 2>&1; echo "status: $$?" >> $@; \ + grep -q $(tst-execstack-prog-noexecstack-msg) $@ \ + && grep -q '^status: 127$$' $@; \ + $(evaluate-test) + +$(objpfx)tst-execstack-needed-noexecstack.out: $(objpfx)tst-execstack-needed + $(test-program-cmd-before-env) \ + $(run-program-env) \ + GLIBC_TUNABLES=glibc.rtld.execstack=0 \ + $(test-program-cmd-after-env) $< \ + > $@ 2>&1; echo "status: $$?" >> $@; \ + grep -q 'error while loading shared libraries:.*cannot enable executable stack as shared object requires:' $@ \ + && grep -q '^status: 127$$' $@; \ + $(evaluate-test) + +$(objpfx)tst-execstack-prog-static-noexecstack.out: $(objpfx)tst-execstack-prog-static + $(test-program-cmd-before-env) \ + $(run-program-env) \ + GLIBC_TUNABLES=glibc.rtld.execstack=0 \ + $< \ + > $@ 2>&1; echo "status: $$?" >> $@; \ + grep -q 'Fatal glibc error: executable stack is not allowed$$' $@ \ + && grep -q '^status: 127$$' $@; \ + $(evaluate-test) endif LDFLAGS-tst-array2 = -Wl,--no-as-needed @@ -1933,6 +2134,8 @@ $(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \ CFLAGS-tst-pie1.c += $(pie-ccflag) CFLAGS-tst-pie2.c += $(pie-ccflag) +CFLAGS-tst-pie-bss.c += $(pie-ccflag) +CFLAGS-tst-pie-address.c += $(pie-ccflag) $(objpfx)tst-piemod1.so: $(libsupport) $(objpfx)tst-pie1: $(objpfx)tst-piemod1.so @@ -2064,6 +2267,13 @@ $(objpfx)tst-dlmopen3.out: $(objpfx)tst-dlmopen1mod.so $(objpfx)tst-dlmopen4.out: $(objpfx)tst-dlmopen1mod.so +CFLAGS-tst-dlmopen4-pic.c += -fPIC +$(objpfx)tst-dlmopen4-pic.out: $(objpfx)tst-dlmopen1mod.so + +CFLAGS-tst-dlmopen4-nonpic.c += -fno-pie +tst-dlmopen4-nonpic-no-pie = yes +$(objpfx)tst-dlmopen4-nonpic.out: $(objpfx)tst-dlmopen1mod.so + $(objpfx)tst-audit1.out: $(objpfx)tst-auditmod1.so tst-audit1-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so @@ -2682,6 +2892,7 @@ LDFLAGS-libmarkermod2-1.so += -Wl,-soname,libmarkermod2.so LDFLAGS-libmarkermod3-1.so += -Wl,-soname,libmarkermod3.so LDFLAGS-libmarkermod4-1.so += -Wl,-soname,libmarkermod4.so LDFLAGS-libmarkermod5-1.so += -Wl,-soname,libmarkermod5.so +LDFLAGS-libmarkermod6-1.so += -Wl,-soname,libmarkermod6.so $(objpfx)libmarkermod%.os : markermodMARKER-VALUE.c $(compile-command.c) \ -DMARKER=marker$(firstword $(subst -, ,$*)) \ @@ -2696,6 +2907,8 @@ $(objpfx)libmarkermod4.so: $(objpfx)libmarkermod4-1.so cp $< $@ $(objpfx)libmarkermod5.so: $(objpfx)libmarkermod5-1.so cp $< $@ +$(objpfx)libmarkermod6.so: $(objpfx)libmarkermod6-1.so + cp $< $@ # tst-glibc-hwcaps-prepend checks that --glibc-hwcaps-prepend is # preferred over auto-detected subdirectories. @@ -2854,7 +3067,7 @@ $(objpfx)tst-rtld-list-diagnostics.out: tst-rtld-list-diagnostics.py \ > $@; \ $(evaluate-test) -$(objpfx)tst-rtld-run-static.out: $(objpfx)/ldconfig +$(objpfx)tst-rtld-run-static.out: $(objpfx)ldconfig $(objpfx)tst-dl_find_object.out: \ $(objpfx)tst-dl_find_object-mod1.so $(objpfx)tst-dl_find_object-mod2.so @@ -3033,11 +3246,11 @@ $(objpfx)tst-tls-allocation-failure-static-patched.out: \ $(objpfx)tst-audit-tlsdesc: $(objpfx)tst-audit-tlsdesc-mod1.so \ $(objpfx)tst-audit-tlsdesc-mod2.so \ $(shared-thread-library) -ifneq (no,$(have-mtls-descriptor)) +ifneq (no,$(have-test-mtls-descriptor)) # The test is valid for all TLS types, but we want to exercise GNU2 # TLS if possible. -CFLAGS-tst-audit-tlsdesc-mod1.c += -mtls-dialect=$(have-mtls-descriptor) -CFLAGS-tst-audit-tlsdesc-mod2.c += -mtls-dialect=$(have-mtls-descriptor) +CFLAGS-tst-audit-tlsdesc-mod1.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-audit-tlsdesc-mod2.c += -mtls-dialect=$(have-test-mtls-descriptor) endif $(objpfx)tst-audit-tlsdesc-dlopen: $(shared-thread-library) $(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-audit-tlsdesc-mod1.so \ @@ -3047,6 +3260,9 @@ $(objpfx)tst-audit-tlsdesc.out: $(objpfx)tst-auditmod-tlsdesc.so tst-audit-tlsdesc-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so $(objpfx)tst-audit-tlsdesc-dlopen.out: $(objpfx)tst-auditmod-tlsdesc.so tst-audit-tlsdesc-dlopen-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc.so +$(objpfx)tst-audit-tlsdesc-dlopen2.out: $(objpfx)tst-auditmod-tlsdesc2.so \ + $(patsubst %, $(objpfx)%.so, $(tlsmod17a-modules)) +tst-audit-tlsdesc-dlopen2-ENV = LD_AUDIT=$(objpfx)tst-auditmod-tlsdesc2.so $(objpfx)tst-dlmopen-twice.out: \ $(objpfx)tst-dlmopen-twice-mod1.so \ @@ -3116,13 +3332,13 @@ $(objpfx)tst-gnu2-tls2.out: \ $(objpfx)tst-gnu2-tls2mod1.so \ $(objpfx)tst-gnu2-tls2mod2.so -ifneq (no,$(have-mtls-descriptor)) -CFLAGS-tst-tlsgap-mod0.c += -mtls-dialect=$(have-mtls-descriptor) -CFLAGS-tst-tlsgap-mod1.c += -mtls-dialect=$(have-mtls-descriptor) -CFLAGS-tst-tlsgap-mod2.c += -mtls-dialect=$(have-mtls-descriptor) -CFLAGS-tst-gnu2-tls2mod0.c += -mtls-dialect=$(have-mtls-descriptor) -CFLAGS-tst-gnu2-tls2mod1.c += -mtls-dialect=$(have-mtls-descriptor) -CFLAGS-tst-gnu2-tls2mod2.c += -mtls-dialect=$(have-mtls-descriptor) +ifneq (no,$(have-test-mtls-descriptor)) +CFLAGS-tst-tlsgap-mod0.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-tlsgap-mod1.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-tlsgap-mod2.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-gnu2-tls2mod0.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-gnu2-tls2mod1.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-gnu2-tls2mod2.c += -mtls-dialect=$(have-test-mtls-descriptor) endif $(objpfx)tst-recursive-tls: $(objpfx)tst-recursive-tlsmallocmod.so @@ -3148,10 +3364,158 @@ $(objpfx)tst-dlopen-tlsreinit4: \ # tst-dlopen-tlsreinitmod3.so. The dependency is provided via # $(objpfx)tst-dlopen-tlsreinitmod1.so. tst-dlopen-tlsreinitmod2.so-no-z-defs = yes -$(objpfx)tst-dlopen-tlsreinit.out: $(objpfx)tst-dlopen-tlsreinitmod1.so \ +$(objpfx)tst-dlopen-tlsreinit1.out: $(objpfx)tst-dlopen-tlsreinitmod1.so \ $(objpfx)tst-dlopen-tlsreinitmod2.so $(objpfx)tst-dlopen-tlsreinitmod3.so # Reuse an audit module which provides ample debug logging. $(objpfx)tst-dlopen-tlsreinit3.out: $(objpfx)tst-auditmod1.so tst-dlopen-tlsreinit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so $(objpfx)tst-dlopen-tlsreinit4.out: $(objpfx)tst-auditmod1.so tst-dlopen-tlsreinit4-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so + +tst-dlopen-auditdup-ENV = LD_AUDIT=$(objpfx)tst-dlopen-auditdup-auditmod.so +$(objpfx)tst-dlopen-auditdup.out: \ + $(objpfx)tst-dlopen-auditdupmod.so $(objpfx)tst-dlopen-auditdup-auditmod.so + +# Reuse an audit module which provides ample debug logging. +tst-rtld-no-malloc-audit-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so +$(objpfx)tst-rtld-no-malloc-audit.out: $(objpfx)tst-auditmod1.so + +# Any shared object should do. +tst-rtld-no-malloc-preload-ENV = LD_PRELOAD=$(objpfx)tst-auditmod1.so +$(objpfx)tst-rtld-no-malloc-preload.out: $(objpfx)tst-auditmod1.so + +LDFLAGS-tst-hash-collision1-mod.so = -Wl,--hash-style=both +$(objpfx)tst-hash-collision1: $(objpfx)tst-hash-collision1-mod.so +LDFLAGS-tst-hash-collision1-mod-gnu.so = -Wl,--hash-style=gnu +$(objpfx)tst-hash-collision1-gnu: $(objpfx)tst-hash-collision1-mod-gnu.so +LDFLAGS-tst-hash-collision1-mod-sysv.so = -Wl,--hash-style=sysv +$(objpfx)tst-hash-collision1-sysv: $(objpfx)tst-hash-collision1-mod-sysv.so +LDFLAGS-tst-hash-collision2-mod1.so = -Wl,--hash-style=both +LDFLAGS-tst-hash-collision2-mod2.so = -Wl,--hash-style=both +$(objpfx)tst-hash-collision2: $(objpfx)tst-hash-collision2-mod1.so \ + $(objpfx)tst-hash-collision2-mod2.so +LDFLAGS-tst-hash-collision2-mod1-gnu.so = -Wl,--hash-style=gnu +LDFLAGS-tst-hash-collision2-mod2-gnu.so = -Wl,--hash-style=gnu +$(objpfx)tst-hash-collision2-gnu: $(objpfx)tst-hash-collision2-mod1-gnu.so \ + $(objpfx)tst-hash-collision2-mod2-gnu.so +LDFLAGS-tst-hash-collision2-mod1-sysv.so = -Wl,--hash-style=sysv +LDFLAGS-tst-hash-collision2-mod2-sysv.so = -Wl,--hash-style=sysv +$(objpfx)tst-hash-collision2-sysv: $(objpfx)tst-hash-collision2-mod1-sysv.so \ + $(objpfx)tst-hash-collision2-mod2-sysv.so +LDFLAGS-tst-hash-collision3-mod.so = \ + -Wl,--version-script=tst-hash-collision3-mod.map +$(objpfx)tst-hash-collision3: $(objpfx)tst-hash-collision3-mod.so + +$(objpfx)tst-tls22: $(objpfx)tst-tls22-vars.o $(objpfx)tst-tls22-mod1.so \ + $(objpfx)tst-tls22-mod2.so $(shared-thread-library) +$(objpfx)tst-tls22-mod1.so: $(objpfx)tst-tls22-mod1.os \ + $(objpfx)tst-tls22-mod1-vars.os $(objpfx)tst-tls22-mod2.so +$(objpfx)tst-tls22-mod2.so: $(objpfx)tst-tls22-mod2.os \ + $(objpfx)tst-tls22-mod2-vars.os +$(objpfx)tst-tls22-gnu2: $(objpfx)tst-tls22-vars.o \ + $(objpfx)tst-tls22-mod1-gnu2.so $(objpfx)tst-tls22-mod2-gnu2.so \ + $(shared-thread-library) +$(objpfx)tst-tls22-mod1-gnu2.so: $(objpfx)tst-tls22-mod1-gnu2.os \ + $(objpfx)tst-tls22-mod1-vars.os $(objpfx)tst-tls22-mod2-gnu2.so +$(objpfx)tst-tls22-mod2-gnu2.so: $(objpfx)tst-tls22-mod2-gnu2.os \ + $(objpfx)tst-tls22-mod2-vars.os +ifneq (no,$(have-test-mtls-descriptor)) +CFLAGS-tst-tls22-gnu2.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-tls22-mod1-gnu2.c += -mtls-dialect=$(have-test-mtls-descriptor) +CFLAGS-tst-tls22-mod2-gnu2.c += -mtls-dialect=$(have-test-mtls-descriptor) +endif +# These reference symbols from the main executable. +tst-tls22-mod1.so-no-z-defs = yes +tst-tls22-mod1-gnu2.so-no-z-defs = yes +tst-tls22-mod2.so-no-z-defs = yes +tst-tls22-mod2-gnu2.so-no-z-defs = yes + +$(objpfx)tst-tls23: $(shared-thread-library) +$(objpfx)tst-tls23.out: $(objpfx)tst-tls23-mod.so + +ifneq (no,$(have-test-mtls-traditional)) +CFLAGS-tst-tls23-mod.c += -mtls-dialect=$(have-test-mtls-traditional) +endif + +ifeq ($(have-test-cc-cflags-fsemantic-interposition),yes) +# Compiler may default to -fno-semantic-interposition. These modules +# must be compiled with -fsemantic-interposition. +modules-semantic-interposition = \ + tst-dlclose-lazy-mod1 \ + tst-dlclose-lazy-mod2 \ + tst-piemod1 \ + unload4mod1 \ + unload4mod2 \ + unload4mod3 \ + unload4mod4 \ +# modules-semantic-interposition + +define enable-semantic-interposition +CFLAGS-$(1).c += -fsemantic-interposition +endef +$(foreach m,$(modules-semantic-interposition),\ + $(eval $(call enable-semantic-interposition,$(m)))) +endif + +# These rules link and run the special elf/tst-nolink-libc-* tests if +# a port adds them to the tests variables. Neither test variant is +# linked against libc.so, but tst-nolink-libc-1 is linked against +# ld.so. The test is always run directly, not under the dynamic +# linker. It is necessary to minimize run-time dependencies, by +# disabling stack protection and unwinding. +CFLAGS-tst-nolink-libc.c += $(no-stack-protector) \ + -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables +$(objpfx)tst-nolink-libc-1: $(objpfx)tst-nolink-libc.o $(objpfx)ld.so + $(LINK.o) -nostdlib -nostartfiles -o $@ $< \ + -Wl,--dynamic-linker=$(objpfx)ld.so,--no-as-needed $(objpfx)ld.so +$(objpfx)tst-nolink-libc-1.out: $(objpfx)tst-nolink-libc-1 $(objpfx)ld.so + $< > $@ 2>&1; $(evaluate-test) +$(objpfx)tst-nolink-libc-2: $(objpfx)tst-nolink-libc.o + $(LINK.o) -nostdlib -nostartfiles -o $@ $< \ + -Wl,--dynamic-linker=$(objpfx)ld.so +$(objpfx)tst-nolink-libc-2.out: $(objpfx)tst-nolink-libc-2 $(objpfx)ld.so + $< > $@ 2>&1; $(evaluate-test) + +$(objpfx)tst-version-hash-zero.out: \ + $(objpfx)tst-version-hash-zero-mod.so \ + $(objpfx)tst-version-hash-zero-refmod.so +LDFLAGS-tst-version-hash-zero-mod.so = \ + -Wl,--version-script=tst-version-hash-zero-mod.map +# The run-time test module tst-version-hash-zero-refmod.so is linked +# to a stub module, tst-version-hash-zero-linkmod.so, to produce an +# expected relocation error. +$(objpfx)tst-version-hash-zero-refmod.so: \ + $(objpfx)tst-version-hash-zero-linkmod.so +LDFLAGS-tst-version-hash-zero-linkmod.so = \ + -Wl,--version-script=tst-version-hash-zero-linkmod.map \ + -Wl,--soname=tst-version-hash-zero-mod.so +$(objpfx)tst-version-hash-zero-refmod.so: \ + $(objpfx)tst-version-hash-zero-linkmod.so +tst-version-hash-zero-refmod.so-no-z-defs = yes + +$(objpfx)tst-dlopen-constructor-null: \ + $(objpfx)tst-dlopen-constructor-null-mod1.so \ + $(objpfx)tst-dlopen-constructor-null-mod2.so +$(objpfx)tst-dlopen-constructor-null-mod2.so: \ + $(objpfx)tst-dlopen-constructor-null-mod1.so + +CFLAGS-tst-origin.c += $(no-stack-protector) +CFLAGS-liborigin-mod.c += $(no-stack-protector) +# Link tst-origin with liborigin-mod.so, but without a full path. +LDFLAGS-tst-origin += -Wl,-rpath,\$$ORIGIN -L$(subst :, -L,$(rpath-link)) +LDLIBS-tst-origin += -lorigin-mod +$(objpfx)tst-origin: +nolink-deps += $(objpfx)liborigin-mod.so +$(objpfx)tst-origin: $(objpfx)liborigin-mod.so +$(objpfx)tst-origin.out: tst-origin.sh $(objpfx)tst-origin + $(SHELL) \ + $< \ + '$(common-objpfx)' \ + '$(test-wrapper-env)' \ + '$(run-program-env)' \ + '$(rpath-link)' \ + tst-origin \ + liborigin-mod.so \ + > $@; \ + $(evaluate-test) + +$(objpfx)tst-dlopen-sgid.out: $(objpfx)tst-dlopen-sgid-mod.so |