[llvm-dev] Backward references in assembly absolute expressions

Petr Hosek via llvm-dev llvm-dev at lists.llvm.org
Tue Apr 19 14:19:02 PDT 2016


While trying to compile an existing codebase which uses handwritten
assembly with LLVM, I ran into an issue around using backward references in
assembly absolute expressions. A simple example can be the following
snippet:

_foo:
  .fill 0x100
_bar:
  .fill _bar - _foo
_baz:
  .fill 0x100

While gas compiles this snippet without any errors, the integrated
assembler throws an error: expected absolute expression for _bar - _foo.

I haven't found any definition of absolute expression in gas manual, and
it's arguable whether this case should be considered an absolute
expression, but at the point of evaluating the directive, the addresses of
backward labels should be already known so this expression could be treated
as absolute. A quick search also revealed several bug reports related to
this issue so it seems like this use case is fairly common.

I'd be happy to try and implement the support for backward references in MC
(unless someone else is already working on this), but before I do invest
more time on this issue, I'd like to ask if this is desirable or if the
lack of support for backward references is intentional?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160419/3413ff4c/attachment.html>


More information about the llvm-dev mailing list