[libunwind] r292723 - X86: swap EBP, ESP on !APPLE
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 26 10:10:42 PST 2017
MichaĆ suggested on the PR that this should be merged to the release branch.
Saleem, what do you think?
On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: compnerd
> Date: Sat Jan 21 10:22:59 2017
> New Revision: 292723
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292723&view=rev
> Log:
> X86: swap EBP, ESP on !APPLE
>
> Restore the `libunwind.h` enumeration values back to the inverted
> values. This diverges from the DWARF definition of the register values.
> However, this allows our header to be compatible with other unwind
> implementations (e.g. HP, GNU Savannah, GCC).
>
> The register IDs are only swapped in the header and need to be unswapped
> when accessing the unwind register file. The flipped EBP and ESP only
> applies on non-Apple x86 targets.
>
> When optimizations were enabled, EBP and ESP would no longer be
> equivalent. As a result, the incorrect access on Linux would manifest
> as a failure to unwind the stack. We can now unwind the stack with and
> without FPO on Linux x86.
>
> Resolves PR30879!
>
> Modified:
> libunwind/trunk/include/libunwind.h
> libunwind/trunk/src/Registers.hpp
>
> Modified: libunwind/trunk/include/libunwind.h
> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=292723&r1=292722&r2=292723&view=diff
> ==============================================================================
> --- libunwind/trunk/include/libunwind.h (original)
> +++ libunwind/trunk/include/libunwind.h Sat Jan 21 10:22:59 2017
> @@ -165,13 +165,8 @@ enum {
> UNW_X86_ECX = 1,
> UNW_X86_EDX = 2,
> UNW_X86_EBX = 3,
> -#if defined(__CloudABI__) || defined(__FreeBSD__)
> - UNW_X86_ESP = 4,
> - UNW_X86_EBP = 5,
> -#else
> UNW_X86_EBP = 4,
> UNW_X86_ESP = 5,
> -#endif
> UNW_X86_ESI = 6,
> UNW_X86_EDI = 7
> };
>
> Modified: libunwind/trunk/src/Registers.hpp
> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=292723&r1=292722&r2=292723&view=diff
> ==============================================================================
> --- libunwind/trunk/src/Registers.hpp (original)
> +++ libunwind/trunk/src/Registers.hpp Sat Jan 21 10:22:59 2017
> @@ -122,9 +122,17 @@ inline uint32_t Registers_x86::getRegist
> return _registers.__edx;
> case UNW_X86_EBX:
> return _registers.__ebx;
> +#if !defined(__APPLE__)
> + case UNW_X86_ESP:
> +#else
> case UNW_X86_EBP:
> +#endif
> return _registers.__ebp;
> +#if !defined(__APPLE__)
> + case UNW_X86_EBP:
> +#else
> case UNW_X86_ESP:
> +#endif
> return _registers.__esp;
> case UNW_X86_ESI:
> return _registers.__esi;
> @@ -154,10 +162,18 @@ inline void Registers_x86::setRegister(i
> case UNW_X86_EBX:
> _registers.__ebx = value;
> return;
> +#if !defined(__APPLE__)
> + case UNW_X86_ESP:
> +#else
> case UNW_X86_EBP:
> +#endif
> _registers.__ebp = value;
> return;
> +#if !defined(__APPLE__)
> + case UNW_X86_EBP:
> +#else
> case UNW_X86_ESP:
> +#endif
> _registers.__esp = value;
> return;
> case UNW_X86_ESI:
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list