1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00
Files
glibc/debug/tst-backtrace1.c
Adhemerval Zanella a12d72019e Disable SFrame support by default
And add extra checks to enable for binutils 2.45 and if the architecture
explicitly enables it.  When SFrame is disabled, all the related code
is also not enabled for backtrace() and _dl_find_object(), so SFrame
backtracking is not used even if the binary has the SFrame segment.

This patch also adds some other related fixes:

  * Fixed an issue with AC_CHECK_PROG_VER, where the READELF_SFRAME
    usage prevented specifying a different readelf through READELF
    environment variable at configure time.

  * Add an extra arch-specific internal definition,
    libc_cv_support_sframe, to disable --enable-sframe on architectures
    that have binutils but not glibc support (s390x).

  * Renamed the tests without the .sframe segment and move the
    tst-backtrace1 from pthread to debug.

  * Use the built compiler strip to remove the .sframe segment,
    instead of the system one (which might not support SFrame).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

Reviewed-by: Sam James <sam@gentoo.org>
2025-07-24 19:38:47 +02:00

85 lines
1.7 KiB
C

/* Copyright (C) 2004-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
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <execinfo.h>
#include <pthread.h>
#include <stdio.h>
#define BT_SIZE 64
void *bt_array[BT_SIZE];
int bt_cnt;
int
do_bt (void)
{
bt_cnt = backtrace (bt_array, BT_SIZE);
return 56;
}
int
call_do_bt (void)
{
return do_bt () + 1;
}
void *
tf (void *arg)
{
if (call_do_bt () != 57)
return (void *) 1L;
return NULL;
}
int
do_test (void)
{
pthread_t th;
if (pthread_create (&th, NULL, tf, NULL))
{
puts ("create failed");
return 1;
}
void *res;
if (pthread_join (th, &res))
{
puts ("join failed");
return 1;
}
if (res != NULL)
{
puts ("thread failed");
return 1;
}
char **text = backtrace_symbols (bt_array, bt_cnt);
if (text == NULL)
{
puts ("backtrace_symbols failed");
return 1;
}
for (int i = 0; i < bt_cnt; ++i)
puts (text[i]);
return 0;
}
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"