Andrew Geissler | 4b7c115 | 2020-11-30 19:55:29 -0600 | [diff] [blame^] | 1 | __ILP32__ is defined for all 32bit architectures with clang e.g. |
| 2 | which is right but it is causing issues on non-x86 architectures |
| 3 | where this condition becomes true and wrongly starts using this |
| 4 | code, this issue is hidden with gcc becuase gcc does not define |
| 5 | __ILP32__ for all 32bit architectures but for selected 64bit arches |
| 6 | who choose to use 32bit ABI e.g. x32 |
| 7 | |
| 8 | Upstream-Status: Pending |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- a/src/debug.c |
| 11 | +++ b/src/debug.c |
| 12 | @@ -944,7 +944,7 @@ static void *getMcontextEip(ucontext_t * |
| 13 | /* Linux */ |
| 14 | #if defined(__riscv) && __riscv_xlen == 32 |
| 15 | return (void*) uc->uc_mcontext.__gregs[REG_PC]; |
| 16 | - #elif defined(__i386__) || defined(__ILP32__) |
| 17 | + #elif defined(__i386__) || (defined(__X86_64__) && defined(__ILP32__)) |
| 18 | return (void*) uc->uc_mcontext.gregs[14]; /* Linux 32 */ |
| 19 | #elif defined(__X86_64__) || defined(__x86_64__) |
| 20 | return (void*) uc->uc_mcontext.gregs[16]; /* Linux 64 */ |
| 21 | @@ -1125,7 +1125,7 @@ void logRegisters(ucontext_t *uc) { |
| 22 | ); |
| 23 | logStackContent((void**)uc->uc_mcontext.__gregs[REG_SP]); |
| 24 | /* Linux x86 */ |
| 25 | - #elif defined(__i386__) || defined(__ILP32__) |
| 26 | + #elif defined(__i386__) || ( defined(__X86_64__) && defined(__ILP32__)) |
| 27 | serverLog(LL_WARNING, |
| 28 | "\n" |
| 29 | "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n" |