Move __libc_int0x80 to an assembly file
Bug: http://b/157081822 If __libc_int0x80 is in a C/C++ file, Clang's coverage instrumentation adds instructions to count the number of times it gets executed [1]. With coverage instrumentation, __libc_sysinfo, used on 32-bit x86, is initialized to the wrong value, causing dl.preinit_system_calls to fail. Moving the function to an assembly file leaves __libc_sysinfo properly initialized. [1] We could change clang so it doesn't instrument functions marked __attribute__((naked)) as a followup. Test: `m CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS=bionic` and run bionic-unit-tests Change-Id: I73558253512392d345de8d5b66d38bb14b308fdf
This commit is contained in:
parent
332065d57e
commit
7b89be78f4
4 changed files with 9 additions and 5 deletions
|
@ -170,6 +170,7 @@ cc_library_static {
|
|||
x86: {
|
||||
srcs: [
|
||||
"arch-x86/bionic/__libc_init_sysinfo.cpp",
|
||||
"arch-x86/bionic/__libc_int0x80.S",
|
||||
"arch-x86/bionic/__set_tls.cpp",
|
||||
],
|
||||
},
|
||||
|
|
|
@ -32,10 +32,6 @@
|
|||
// This file is compiled without stack protection, because it runs before TLS
|
||||
// has been set up.
|
||||
|
||||
__LIBC_HIDDEN__ __attribute__((__naked__)) void __libc_int0x80() {
|
||||
__asm__ volatile("int $0x80; ret");
|
||||
}
|
||||
|
||||
__LIBC_HIDDEN__ void __libc_init_sysinfo() {
|
||||
bool unused;
|
||||
__libc_sysinfo = reinterpret_cast<void*>(__bionic_getauxval(AT_SYSINFO, &unused));
|
||||
|
|
7
libc/arch-x86/bionic/__libc_int0x80.S
Normal file
7
libc/arch-x86/bionic/__libc_int0x80.S
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <private/bionic_asm.h>
|
||||
|
||||
// void __libc_int0x80();
|
||||
ENTRY_PRIVATE(__libc_int0x80)
|
||||
int $0x80
|
||||
ret
|
||||
END(__libc_int0x80)
|
|
@ -123,7 +123,7 @@ __LIBC_HIDDEN__ void __libc_init_vdso(libc_globals* globals);
|
|||
|
||||
#if defined(__i386__)
|
||||
__LIBC_HIDDEN__ extern void* __libc_sysinfo;
|
||||
__LIBC_HIDDEN__ void __libc_int0x80();
|
||||
extern "C" __LIBC_HIDDEN__ void __libc_int0x80();
|
||||
__LIBC_HIDDEN__ void __libc_init_sysinfo();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue