[PATCH v13 3/4] elf: Issue la_symbind for bind-now (BZ #23734)
Szabolcs Nagy
szabolcs.nagy@arm.com
Wed Feb 2 13:57:52 GMT 2022
The 02/01/2022 11:46, Adhemerval Zanella via Libc-alpha wrote:
> The audit symbind callback is not called for binaries built with
> -Wl,-z,now or when LD_BIND_NOW=1 is used, nor the PLT tracking callbacks
> (plt_enter and plt_exit) since this would change the expected
> program semantics (where no PLT is expected) and would have performance
> implications (such as for BZ#15533).
>
> LAV_CURRENT is also bumped to indicate the audit ABI change (where
> la_symbind flags are set by the loader to indicate no possible PLT
> trace).
>
> To handle powerpc64 ELFv1 function descriptor, _dl_audit_symbind
> requires to know whether bind-now is used so the symbol value is
> updated to function text segment instead of the OPD (for lazy binding
> this is done by PPC64_LOAD_FUNCPTR on _dl_runtime_resolve).
>
> Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
> powerpc64-linux-gnu.
with a default bind now toolchain i see
FAIL: elf/tst-audit25a
> +$(objpfx)tst-audit25a.out: $(objpfx)tst-auditmod25.so
> +$(objpfx)tst-audit25a: $(objpfx)tst-audit25mod1.so \
> + $(objpfx)tst-audit25mod2.so \
> + $(objpfx)tst-audit25mod3.so \
> + $(objpfx)tst-audit25mod4.so
> +$(objpfx)tst-audit25mod1.so: $(objpfx)tst-audit25mod3.so
> +LDFLAGS-tst-audit25mod1.so = -Wl,-z,now
> +$(objpfx)tst-audit25mod2.so: $(objpfx)tst-audit25mod4.so
> +LDFLAGS-tst-audit25mod2.so = -Wl,-z,lazy
> +tst-audit25a-ARGS = -- $(host-test-program-cmd)
i guess we need to add -Wl,-z,lazy explicitly to tst-audit25a too
> + /* tst-audit25a is build with -Wl,-z,lazy and tst-audit25mod1 with
> + -Wl,-z,now; so only tst_audit25mod3_func1 should be expected to
> + have LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT. */
> + TEST_COMPARE_STRING (result.err.buffer,
> + "la_symbind: tst_audit25mod3_func1 1\n"
> + "la_symbind: tst_audit25mod1_func1 0\n"
> + "la_symbind: tst_audit25mod1_func2 0\n"
> + "la_symbind: tst_audit25mod2_func1 0\n"
> + "la_symbind: tst_audit25mod4_func1 0\n"
> + "la_symbind: tst_audit25mod2_func2 0\n");
> +
tst-audit25a.c:93: error: string comparison failed
string length: 216 bytes
left (evaluated from result.err.buffer):
"la_symbind: tst_audit25mod3_func1 1\nla_symbind: tst_audit25mod1_func1 1\nla_symbind: tst_audit25mod2_func1 1\nla_symbind: tst_audit25mod1_func2 1\nla_symbind: tst_audit25mod2_func2 1\nla_symbind: tst_audit25mod4_func1 0\n"
6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 33 5F 66 75 6E 63 31 20 31 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 31 5F 66 75 6E 63 31 20 31 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 32 5F 66 75 6E 63 31 20 31 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 31 5F 66 75 6E 63 32 20 31 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 32 5F 66 75 6E 63 32 20 31 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 34 5F 66 75 6E 63 31 20 30 0A
right (evaluated from "la_symbind: tst_audit25mod3_func1 1\n" "la_symbind: tst_audit25mod1_func1 0\n" "la_symbind: tst_audit25mod1_func2 0\n" "la_symbind: tst_audit25mod2_func1 0\n" "la_symbind: tst_audit25mod4_func1 0\n" "la_symbind: tst_audit25mod2_func2 0\n"):
"la_symbind: tst_audit25mod3_func1 1\nla_symbind: tst_audit25mod1_func1 0\nla_symbind: tst_audit25mod1_func2 0\nla_symbind: tst_audit25mod2_func1 0\nla_symbind: tst_audit25mod4_func1 0\nla_symbind: tst_audit25mod2_func2 0\n"
6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 33 5F 66 75 6E 63 31 20 31 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 31 5F 66 75 6E 63 31 20 30 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 31 5F 66 75 6E 63 32 20 30 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 32 5F 66 75 6E 63 31 20 30 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 34 5F 66 75 6E 63 31 20 30 0A 6C 61 5F 73 79 6D 62 69 6E 64 3A 20 74 73 74 5F 61 75 64 69 74 32 35 6D 6F 64 32 5F 66 75 6E 63 32 20 30 0A
error: 1 test failures
and
$ readelf -d elf/tst-audit25a |grep -i flags
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW PIE
More information about the Libc-alpha
mailing list