diff options
author | Stefan Liebler <stli@linux.ibm.com> | 2023-07-13 15:13:48 +0200 |
---|---|---|
committer | Stefan Liebler <stli@linux.ibm.com> | 2023-07-19 13:18:06 +0200 |
commit | 5d72e7e41a7860b911251bfc8dd3641460cc20a0 (patch) | |
tree | d10ccc37da451376db9c6fea437494561791d66a /elf | |
parent | 8b9a0af8ca012217bf90d1dc0694f85b49ae09da (diff) | |
download | glibc-5d72e7e41a7860b911251bfc8dd3641460cc20a0.zip glibc-5d72e7e41a7860b911251bfc8dd3641460cc20a0.tar.gz glibc-5d72e7e41a7860b911251bfc8dd3641460cc20a0.tar.bz2 |
Fix getting return address in elf/tst-audit28.c.
Starting with commit 1bcfe0f732066ae5336b252295591ebe7e51c301, the
test was enhanced and the object for __builtin_return_address (0)
is searched with _dl_find_object.
Unfortunately on e.g. s390 (31bit), a postprocessing step is needed
as the highest bit has to be masked out. This can be done with
__builtin_extract_return_addr.
Without this postprocessing, _dl_find_object returns with -1 and the
content of dlfo is invalid, which may lead to segfaults in basename.
Therefore those checks are now only done on success.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'elf')
-rw-r--r-- | elf/tst-auditmod28.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/elf/tst-auditmod28.c b/elf/tst-auditmod28.c index f6dfbbe..3518020 100644 --- a/elf/tst-auditmod28.c +++ b/elf/tst-auditmod28.c @@ -73,12 +73,19 @@ la_version (unsigned int current) /* Check _dl_find_object. */ struct dl_find_object dlfo; - TEST_COMPARE (_dl_find_object (__builtin_return_address (0), &dlfo), 0); - /* "ld.so" is seen with --enable-hardcoded-path-in-tests. */ - if (strcmp (basename (dlfo.dlfo_link_map->l_name), "ld.so") != 0) - TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LD_SO); - TEST_COMPARE (_dl_find_object (dlsym (handle, "environ"), &dlfo), 0); - TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LIBC_SO); + void *ret_addr = __builtin_extract_return_addr (__builtin_return_address (0)); + int ret_dl_find_object =_dl_find_object (ret_addr, &dlfo); + TEST_COMPARE (ret_dl_find_object, 0); + if (ret_dl_find_object == 0) + { + /* "ld.so" is seen with --enable-hardcoded-path-in-tests. */ + if (strcmp (basename (dlfo.dlfo_link_map->l_name), "ld.so") != 0) + TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LD_SO); + } + ret_dl_find_object = _dl_find_object (dlsym (handle, "environ"), &dlfo); + TEST_COMPARE (ret_dl_find_object, 0); + if (ret_dl_find_object == 0) + TEST_COMPARE_STRING (basename (dlfo.dlfo_link_map->l_name), LIBC_SO); TEST_COMPARE (_dl_find_object ((void *) 1, &dlfo), -1); TEST_COMPARE (_dl_find_object ((void *) -1, &dlfo), -1); |