Bug 201741

Summary: [4.19 Regression] i386 vDSO has incorrect unwind info
Product: Platform Specific/Hardware Reporter: H.J. Lu (hjl.tools)
Component: i386Assignee: platform_i386
Status: NEW ---    
Severity: normal CC: fweimer
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.19 Subsystem:
Regression: No Bisected commit-id:
Attachments: A testcase

Description H.J. Lu 2018-11-20 21:53:54 UTC
Created attachment 279555 [details]
A testcase

commit 379d98ddf41344273d9718556f761420f4dc80b3
Author: Alistair Strachan <astrachan@google.com>
Date:   Fri Aug 3 10:39:31 2018 -0700

    x86: vdso: Use $LD instead of $CC to link
    
    The vdso{32,64}.so can fail to link with CC=clang when clang tries to find
    a suitable GCC toolchain to link these libraries with.
    
    /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o:
      access beyond end of merged section (782)

breaks i386 vDSO with incorrect unwind info.  The testcase here should
report:

[hjl@gnu-hsw-1 tmp]$ gcc -g -O2 -funwind-tables -m32 foo.c
[hjl@gnu-hsw-1 tmp]$ ./a.out 
Obtained backtrace with 7 functions
Function 0: ./a.out() [0x8049272]
Function 1: linux-gate.so.1(__kernel_sigreturn+0) [0xf7f990b0]
Function 2: linux-gate.so.1(__kernel_vsyscall+0x9) [0xf7f99099]
Function 3: /lib/libc.so.6(__read+0x2b) [0xf7ea72ab]
Function 4: ./a.out() [0x80493a9]
Function 5: ./a.out() [0x80493f3]
Function 6: ./a.out() [0x80493f3]
[hjl@gnu-hsw-1 tmp]$ 

But kernel 4.19 got

[hjl@gnu-cfl-1 tmp]$ ./a.out 
Obtained backtrace with 4 functions
Failure on line 67
[hjl@gnu-cfl-1 tmp]$ 

Revert the commit fixes i386 vDSO.
Comment 1 Florian Weimer 2018-12-14 20:47:41 UTC
The GNU_EH_FRAME segment is actually empty in our builds.  This breaks unwinding across signal handlers on i386 because the libgcc unwinder does not recognize i386 __kernel_sigreturn as a signal handler frame anymore.