diff mbox

AArch64: Fix the gdb build with musl libc

Message ID c3b4c41c-b4eb-7d10-6191-8e80d1bfc806@arm.com
State New
Headers show

Commit Message

Szabolcs Nagy Dec. 14, 2018, 6 p.m. UTC
Including asm/sigcontext.h together with libc headers is not valid. In
general linux headers may not work with libc headers, so mixing them
should be avoided, especially when the linux header defines types that
are also exposed in libc headers.

In case of asm/sigcontext.h glibc happens to work because glibc signal.h
directly includes it, but e.g. in musl libc signal.h replicates the
sigcontext.h definitions in an abi compatible way which are in conflict
with the linux definitions when both headers are included.

Since old linux headers or old libc headers may not have the necessary
definitions, gdb has to replicate the definitions it relies on anyway.
Which is fine since all definitions must be ABI stable. For linux apis
that are not available via libc headers, replicating the definitions in
gdb is the most reliable way to use them.

Note: asm/ptrace.h includes asm/sigcontext.h in some versions of linux
headers, which is just as problematic and should be fixed in linux.

gdb/ChangeLog:

2018-12-14  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* nat/aarch64-sve-linux-ptrace.h: Include signal.h instead of
	asm/sigcontext.h.

Comments

Alan Hayward Dec. 17, 2018, 10:21 a.m. UTC | #1
> On 14 Dec 2018, at 18:00, Szabolcs Nagy <Szabolcs.Nagy@arm.com> wrote:

> 

> Including asm/sigcontext.h together with libc headers is not valid. In

> general linux headers may not work with libc headers, so mixing them

> should be avoided, especially when the linux header defines types that

> are also exposed in libc headers.

> 

> In case of asm/sigcontext.h glibc happens to work because glibc signal.h

> directly includes it, but e.g. in musl libc signal.h replicates the

> sigcontext.h definitions in an abi compatible way which are in conflict

> with the linux definitions when both headers are included.

> 

> Since old linux headers or old libc headers may not have the necessary

> definitions, gdb has to replicate the definitions it relies on anyway.

> Which is fine since all definitions must be ABI stable. For linux apis

> that are not available via libc headers, replicating the definitions in

> gdb is the most reliable way to use them.

> 

> Note: asm/ptrace.h includes asm/sigcontext.h in some versions of linux

> headers, which is just as problematic and should be fixed in linux.


I’m assuming that this fix still works with the 3 part "arm64/sve: UAPI:
Disentangle ptrace.h from sigcontext.h” kernel patch from Dave Martin?

If so, then LGTM.

> 

> gdb/ChangeLog:

> 

> 2018-12-14  Szabolcs Nagy  <szabolcs.nagy@arm.com>

> 

> 	* nat/aarch64-sve-linux-ptrace.h: Include signal.h instead of

> 	asm/sigcontext.h.

> <sig.diff>
Szabolcs Nagy Dec. 17, 2018, 10:46 a.m. UTC | #2
On 17/12/2018 10:21, Alan Hayward wrote:
>> On 14 Dec 2018, at 18:00, Szabolcs Nagy <Szabolcs.Nagy@arm.com> wrote:

>>

>> Including asm/sigcontext.h together with libc headers is not valid. In

>> general linux headers may not work with libc headers, so mixing them

>> should be avoided, especially when the linux header defines types that

>> are also exposed in libc headers.

>>

>> In case of asm/sigcontext.h glibc happens to work because glibc signal.h

>> directly includes it, but e.g. in musl libc signal.h replicates the

>> sigcontext.h definitions in an abi compatible way which are in conflict

>> with the linux definitions when both headers are included.

>>

>> Since old linux headers or old libc headers may not have the necessary

>> definitions, gdb has to replicate the definitions it relies on anyway.

>> Which is fine since all definitions must be ABI stable. For linux apis

>> that are not available via libc headers, replicating the definitions in

>> gdb is the most reliable way to use them.

>>

>> Note: asm/ptrace.h includes asm/sigcontext.h in some versions of linux

>> headers, which is just as problematic and should be fixed in linux.

> 

> I’m assuming that this fix still works with the 3 part "arm64/sve: UAPI:

> Disentangle ptrace.h from sigcontext.h” kernel patch from Dave Martin?

> 

> If so, then LGTM.


yes,
committed.
thanks.

>>

>> gdb/ChangeLog:

>>

>> 2018-12-14  Szabolcs Nagy  <szabolcs.nagy@arm.com>

>>

>> 	* nat/aarch64-sve-linux-ptrace.h: Include signal.h instead of

>> 	asm/sigcontext.h.

>> <sig.diff>

>
diff mbox

Patch

diff --git a/gdb/nat/aarch64-sve-linux-ptrace.h b/gdb/nat/aarch64-sve-linux-ptrace.h
index 029e753ffe..172ae39432 100644
--- a/gdb/nat/aarch64-sve-linux-ptrace.h
+++ b/gdb/nat/aarch64-sve-linux-ptrace.h
@@ -20,7 +20,7 @@ 
 #ifndef AARCH64_SVE_LINUX_PTRACE_H
 #define AARCH64_SVE_LINUX_PTRACE_H
 
-#include <asm/sigcontext.h>
+#include <signal.h>
 #include <sys/utsname.h>
 #include <sys/ptrace.h>
 #include <asm/ptrace.h>