[PATCH] Fix section type of .eh_frame on Linux x86_64

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Mar 13 12:27:53 GMT 2020



On 11/03/2020 18:27, Fangrui Song via Libc-alpha wrote:
> Clang since https://reviews.llvm.org/D73999 will error for the wrong
> sh_type.

It will make eh_frame section of sigaction object to have the
SHT_X86_64_UNWIND, but it seems that 'ld.bfd' at least ignore and
set the resulting eh_frame sh_type for libc.so to SHT_PROGBITS
anyway. The 'as' also still generate SHT_PROGBITS for code that
requires a eh_frame (C++ with exception handling that emits a
gcc_except_table section, for instance).

Setting the eh_frame in assembly routines is not a common practice,
the only other code that I could find that actually does it is
Linux.  For i686 vDSO is also uses 'progbits':

arch/x86/entry/vdso/vdso32/sigreturn.S

 36         .section .eh_frame,"a",@progbits                                                               
 37 .LSTARTFRAMEDLSI1:

The change should be ok, but I would like to understand better why
exactly SHT_X86_64_UNWIND should be used for eh_frame, why binutils
does not seems to use it to eh_frame, and why clang is now not
accepting the eh_frame with SHT_PROGBITS type.

> ---
>  sysdeps/unix/sysv/linux/x86_64/sigaction.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
> index c58a77c5c6..3b730bc9e3 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
> +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
> @@ -80,7 +80,7 @@ asm									\
>     "	movq $" #syscall ", %rax\n"					\
>     "	syscall\n"							\
>     ".LEND_" #name ":\n"							\
> -   ".section .eh_frame,\"a\",@progbits\n"				\
> +   ".section .eh_frame,\"a\",@unwind\n"					\
>     ".LSTARTFRAME_" #name ":\n"						\
>     "	.long .LENDCIE_" #name "-.LSTARTCIE_" #name "\n"		\
>     ".LSTARTCIE_" #name ":\n"						\
> 


More information about the Libc-alpha mailing list