[LLVMdev] llvm-ld stripping debugging symbols?

Robin Sommer robinsommer at web.de
Sun Oct 31 18:02:08 PDT 2010


It seems that llvm-ld is stripping debugging symbols even with
optimizations disabled:

    > cat main.c 
    int main()
    {
        int a = 42; 
        return a;
    }
    > clang -c -g -emit-llvm -o main.bc main.c
    > llvm-ld -disable-opt -b=a.out.bc main.bc 
    > clang -g a.out.bc -o a.out 
    
    >gdb a.out
    [...]
    (gdb) break main
    Breakpoint 1 at 0x40045b: file main.c, line 4.
    (gdb) run
    Starting program: a.out 
    
    Breakpoint 1, main () at main.c:4
    4           int a = 42; 
    (gdb) print a
    No symbol "a" in current context.

However, if I leave llvm-ld out of the picture, it works:

    > clang -g main.bc -o a.out 
    > gdb a.out
    (gdb) break main
    Breakpoint 1 at 0x40045b: file main.c, line 4.
    (gdb) run
    Starting program: a.out 
    
    Breakpoint 1, main () at main.c:4
    4           int a = 42; 
    (gdb) print a
    $1 = 0


Am I missing something? 

This is with LLVM/clang 2.8 on x86_64 Linux.

Thanks,

Robin

-- 
Robin Sommer * Phone +1 (510) 722-6541 * robin at icir.org 
ICSI/LBNL    * Fax   +1 (510) 666-2956 *   www.icir.org



More information about the llvm-dev mailing list