[llvm-bugs] [Bug 44516] New: Wasm debug line table addresses in linked binary should be offsets in the binary

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 10 15:18:13 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=44516

            Bug ID: 44516
           Summary: Wasm debug line table addresses in linked binary
                    should be offsets in the binary
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: wasm
          Assignee: unassignedbugs at nondot.org
          Reporter: dschuff at google.com
                CC: llvm-bugs at lists.llvm.org, sbc at chromium.org

Summary: The .debug_line table output for a wasm object file containing 2
functions foo and bar appears to be correct. In particular each address in the
line table is an offset from the start of the code section, and appears to be
correct.
After linking, the addresses should be offsets from the start of the binary
file, but it appears that each address is an offset from the start of the
function (which is different even from its input state as a section offset).

I'm guessing this has something to do with the way the linker considers
functions to be their own sections.

Test input:
main.c:

int foo (int arg) {
  int a = 1;
  {
    int b = 2;
    arg = b;
  }
  return arg + a;;
}

int bar (int arg) {
  int aa[arg];
  //void* bb = __builtin_alloca(arg);
  char cc;
  return 0;
}

int baz(void);
int main(void) {
  return foo(2) + baz();
}

<baz.c omitted>

wasm-objdump output for foo and bar in main.o
000002 func[1] <foo>:
 000003: 09 7f                      | local[0..8] type=i32
 000005: 23 80 80 80 80 00          | global.get 0 <env.__stack_pointer>
 00000b: 21 01                      | local.set 1
 00000d: 41 10                      | i32.const 16
 00000f: 21 02                      | local.set 2
 000011: 20 01                      | local.get 1
 000013: 20 02                      | local.get 2
 000015: 6b                         | i32.sub
 000016: 21 03                      | local.set 3
 000018: 41 02                      | i32.const 2
 00001a: 21 04                      | local.set 4
 00001c: 41 01                      | i32.const 1
 00001e: 21 05                      | local.set 5
 000020: 20 03                      | local.get 3
 000022: 20 00                      | local.get 0
 000024: 36 02 0c                   | i32.store 2 12
 000027: 20 03                      | local.get 3
 000029: 20 05                      | local.get 5
 00002b: 36 02 08                   | i32.store 2 8
 00002e: 20 03                      | local.get 3
 000030: 20 04                      | local.get 4
 000032: 36 02 04                   | i32.store 2 4
 000035: 20 03                      | local.get 3
 000037: 28 02 04                   | i32.load 2 4
 00003a: 21 06                      | local.set 6
 00003c: 20 03                      | local.get 3
 00003e: 20 06                      | local.get 6
 000040: 36 02 0c                   | i32.store 2 12
 000043: 20 03                      | local.get 3
 000045: 28 02 0c                   | i32.load 2 12
 000048: 21 07                      | local.set 7
 00004a: 20 03                      | local.get 3
 00004c: 28 02 08                   | i32.load 2 8
 00004f: 21 08                      | local.set 8
 000051: 20 07                      | local.get 7
 000053: 20 08                      | local.get 8
 000055: 6a                         | i32.add
 000056: 21 09                      | local.set 9
 000058: 20 09                      | local.get 9
 00005a: 0f                         | return
 00005b: 0b                         | end
00005d func[2] <bar>:
 00005e: 09 7f                      | local[0..8] type=i32
 000060: 23 80 80 80 80 00          | global.get 0 <env.__stack_pointer>
 000066: 21 01                      | local.set 1
 000068: 41 10                      | i32.const 16
 00006a: 21 02                      | local.set 2
 00006c: 20 01                      | local.get 1
 00006e: 20 02                      | local.get 2
 000070: 6b                         | i32.sub
 000071: 21 03                      | local.set 3
 000073: 20 03                      | local.get 3
 000075: 21 04                      | local.set 4
 000077: 41 00                      | i32.const 0
 000079: 21 05                      | local.set 5
 00007b: 20 04                      | local.get 4
 00007d: 20 00                      | local.get 0
 00007f: 36 02 0c                   | i32.store 2 12
 000082: 20 04                      | local.get 4
 000084: 28 02 0c                   | i32.load 2 12
 000087: 21 06                      | local.set 6
 000089: 20 03                      | local.get 3
 00008b: 21 07                      | local.set 7
 00008d: 20 07                      | local.get 7
 00008f: 21 08                      | local.set 8
 000091: 20 04                      | local.get 4
 000093: 20 08                      | local.get 8
 000095: 36 02 08                   | i32.store 2 8
 000098: 20 04                      | local.get 4
 00009a: 20 06                      | local.get 6
 00009c: 36 02 04                   | i32.store 2 4
 00009f: 20 04                      | local.get 4
 0000a1: 28 02 08                   | i32.load 2 8
 0000a4: 21 09                      | local.set 9
 0000a6: 20 09                      | local.get 9
 0000a8: 21 03                      | local.set 3
 0000aa: 20 05                      | local.get 5
 0000ac: 0f                         | return
 0000ad: 0b                         | end

llvm-dwarfdump line table output for main.o:
Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000002      1      0      1   0             0  is_stmt
0x0000000000000027      2      7      1   0             0  is_stmt prologue_end
0x000000000000002e      4      9      1   0             0  is_stmt
0x0000000000000035      5     11      1   0             0  is_stmt
0x000000000000003c      5      9      1   0             0 
0x0000000000000043      7     10      1   0             0  is_stmt
0x000000000000004a      7     16      1   0             0 
0x0000000000000051      7     14      1   0             0 
0x0000000000000058      7      3      1   0             0 
0x000000000000005c      7      3      1   0             0  end_sequence
<-below here are lines for bar()->
0x000000000000005d     10      0      1   0             0  is_stmt
0x0000000000000082     11     10      1   0             0  is_stmt prologue_end
0x0000000000000089     11      3      1   0             0 
0x000000000000009f     15      1      1   0             0  is_stmt
0x00000000000000ae     15      1      1   0             0  is_stmt end_sequence
0x00000000000000af     18      0      1   0             0  is_stmt
0x00000000000000dc     19     10      1   0             0  is_stmt prologue_end
0x00000000000000e6     19     19      1   0             0 
0x00000000000000ee     19     17      1   0             0 
0x00000000000000f5     19      3      1   0             0 
0x000000000000010c     19      3      1   0             0  end_sequence

llvm-dwarfdump line table output for linked binary:
Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000005      1      0      1   0             0  is_stmt
0x000000000000002a      2      7      1   0             0  is_stmt prologue_end
0x0000000000000031      4      9      1   0             0  is_stmt
0x0000000000000038      5     11      1   0             0  is_stmt
0x000000000000003f      5      9      1   0             0 
0x0000000000000046      7     10      1   0             0  is_stmt
0x000000000000004d      7     16      1   0             0 
0x0000000000000054      7     14      1   0             0 
0x000000000000005b      7      3      1   0             0 
0x000000000000005f      7      3      1   0             0  end_sequence
<- These are still for bar() but the addresses reset->
0x0000000000000000     10      0      1   0             0  is_stmt
0x0000000000000025     11     10      1   0             0  is_stmt prologue_end
0x000000000000002c     11      3      1   0             0 
0x0000000000000042     15      1      1   0             0  is_stmt
0x0000000000000051     15      1      1   0             0  is_stmt end_sequence
0x0000000000000060     18      0      1   0             0  is_stmt
0x000000000000008d     19     10      1   0             0  is_stmt prologue_end
0x0000000000000097     19     19      1   0             0 
0x000000000000009f     19     17      1   0             0 
0x00000000000000a6     19      3      1   0             0 
0x00000000000000bd     19      3      1   0             0  end_sequence

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200110/bdd21d53/attachment-0001.html>


More information about the llvm-bugs mailing list