LLVM assembler and Jump tables

Hello,
I’m not quite sure this is the correct forum, but was looking for some help on how to implement something in assembly that will compile with LLVM on windows.
I have the following jump table defined in a MASM file that I’m trying to port over to AT&T syntax so that I can do some things in llvm-mc passes with the program:

$L_140025138           DWORD IMAGEREL $L_140003492
          DWORD IMAGEREL $L_14000348b
          DWORD IMAGEREL $L_14000347d
          DWORD IMAGEREL $L_14000346f
          DWORD IMAGEREL $L_140003461
          DWORD IMAGEREL $L_140003453
          DWORD IMAGEREL $L_140003445
          DWORD IMAGEREL $L_140003437
          DWORD IMAGEREL $L_140003429

Converting to AT&T syntax I believe it should look like this:

.L_140025138:
          .long .L_140003492-__ImageBase
          .long .L_14000348b-__ImageBase
          .long .L_14000347d-__ImageBase
          .long .L_14000346f-__ImageBase
          .long .L_140003461-__ImageBase
          .long .L_140003453-__ImageBase
          .long .L_140003445-__ImageBase
          .long .L_140003437-__ImageBase
          .long .L_140003429-__ImageBase

When compiling with clang-cl, it produces errors such as

error: symbol '__ImageBase' can not be undefined in a subtraction expression
          .long .L_140003429-__ImageBase

I wrote some assembly to print out the __ImageBase of the executable, so I know it is resolving it during link/runtime, but I’m kind of at loss as to how to handle it as a calculation for the label. Any pointers would be greatly appreciated.

I think you want something like .rva .L_140003492.

1 Like