boringssl/util/fipstools/testdata/ppc64le-TOCWithOffset/in.s
David Benjamin 055375ef26 Support more complex offset / symbol section interleavings.
LLVM likes to emit offsets of the form foo@toc@ha+16, which we didn't
support. Generalize parseMemRef to handle this case and avoid some of
the repeated offset special-cases. Offsets are now always folded into
the SymbolRef.

This still does not quite implement a fully general GAS-compatible
parser as GAS's parser is insane. GAS in x86_64 will happily accept
things like:

  1@GOTPCREL+foo
  blah1@GOTPCREL-blah2+blah3-blah4+blah5 # GOTPCREL modifies blah5, rest
                                         # of expression is an offset.

GAS actually textually pulls @GOTPCREL out of the input partway through
parsing the expression and parses the modified input! Then its normal
parser goes and maintains a running expression of a specific type and,
at each term, attempts to merge it into what it currently has. So adding
and subtracting symbols is not commutative (signs must alternate or so)
and the last symbol wins.

However its PPC64 parser is not as general and just terminates each
expression after @toc@ha and friends, except that it special-cases
foo@toc@ha+16: if it can parse one more expression after @toc@ha AND it
is a constant expression, then it is added into the running offset.
Otherwise it leaves that data unconsumed.

This is all ridiculous, so just generalize our parser slightly to cover
foo@toc@ha+16 and see how far we get from there.

Change-Id: I65970791fc10fb2638fd7be8cc841900eb997c9c
Reviewed-on: https://boringssl-review.googlesource.com/16944
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-06-06 22:48:26 +00:00

24 lines
414 B
ArmAsm

.text
foo:
# TOC references may have offsets.
addis 3, 2, 5+foo@toc@ha
addi 3, 3, 10+foo@toc@l
addis 3, 2, 15+foo@toc@ha
addi 3, 3, 20+foo@toc@l
addis 4, 2, foo@toc@ha
addi 4, 4, foo@toc@l
addis 5, 2, 5+foo@toc@ha
ld 5, 10+foo@toc@l(5)
addis 4, 2, foo-10@toc@ha
addi 4, 4, foo-10@toc@l
addis 4, 2, foo@toc@ha+25
addi 4, 4, foo@toc@l+25
addis 4, 2, 1+foo-2@toc@ha+3
addi 4, 4, 1+foo-2@toc@l+3