1

I have this line of code in YASM (32-bit code):

call 0xC0000000

which works correctly, but which gives me this warning:

warning: value does not fit in signed 32 bit field

There are many ways to work around the warning, or to suppress, even ignore it completely.
But what I would like to know is:

What is the proper way to avoid this warning in the first place?

user541686
  • 205,094
  • 128
  • 528
  • 886
  • NASM doesn't warn here. Perhaps, YASM is treating `0xC0000000` as an unsigned value and for some reason unbeknownst to me expecting a signed address as the argument for `call`. Or, quite likely, it's calculating the distance from the next instruction to `0xC0000000` as an unsigned value and then trying to fit it into the signed 32-bit displacement in `call`. Either way, the warning doesn't make much sense. Btw, does the disassembly look right at least or is YASM being naughty? – Alexey Frunze Feb 12 '13 at 03:49
  • @AlexeyFrunze: Wow, this is really confusing then. I'd never even looked at the disassembly until now. `objdump` gives me `e8 33 82 17 c0 ... call 0xc0178400` which is really weird and doesn't make much sense to me. The funny thing is, the code seems to work as intended o.O I'm confused what's going on now... it doesn't even look like a relative address to me! – user541686 Feb 12 '13 at 03:55
  • Does objdump take into account the load address? I mean, it's probably useless to feed an object file into objdump as the addresses aren't fixed yet, it should be the executable. – Alexey Frunze Feb 12 '13 at 03:58
  • @AlexeyFrunze: I think it assumes the load address is zero -- I'm running `objdump -D -mi386 -b binary MyRawExecutable.bin` which outputs text like `Disassembly of section .data: 00000000 <.data>: ...` – user541686 Feb 12 '13 at 04:01
  • Well, then it's probably working. Don't know what to do with the warning, though. – Alexey Frunze Feb 12 '13 at 07:23

1 Answers1

1

Looks like replacing it with -0x40000000 fixes it (because this value is signed).

user541686
  • 205,094
  • 128
  • 528
  • 886
  • 1
    @BulatM.: The reason is literally what I already wrote -- it's because the value is signed, and like the error says, `0xC0000000` as a signed integer doesn't fit into 32 bits. But `0x40000000` does, and so does its negation. – user541686 Sep 11 '16 at 19:20