A couple of Aarch64 FIPS delocate fixes.

Clang 12 in opt mode produces a couple of assembly patterns that were
not handled by delocate.

Firstly, two-digit vector indexes were just a simple omission. Fixed.

Secondly, Clang puts symbol deltas in .byte directives, and bit-shifts
them. The .byte directive was not considered to be a symbol-containing
directive because it's too small, but it could store deltas.
Additionally, bit-shifting of symbol expressions was not supported.
Fixed.

Change-Id: I796299821f5ac7d3639fa6243c5d9bd5342bbddf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47064
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
grpc-202302
Adam Langley 4 years ago committed by CQ bot account: commit-bot@chromium.org
parent eec7f32470
commit 2e54edf323
  1. 21
      util/fipstools/delocate/delocate.peg
  2. 4254
      util/fipstools/delocate/delocate.peg.go
  3. 4
      util/fipstools/delocate/testdata/aarch64-Basic/in.s
  4. 4
      util/fipstools/delocate/testdata/aarch64-Basic/out.s
  5. 5
      util/fipstools/delocate/testdata/x86_64-LabelRewrite/in2.s
  6. 6
      util/fipstools/delocate/testdata/x86_64-LabelRewrite/out.s

@ -38,14 +38,19 @@ Arg <- QuotedArg / [[0-9a-z%+\-*_@.]]*
QuotedArg <- '"' QuotedText '"'
QuotedText <- (EscapedChar / [^"])*
LabelContainingDirective <- LabelContainingDirectiveName WS SymbolArgs
LabelContainingDirectiveName <- ".xword" / ".word" / ".long" / ".set" / ".8byte" / ".4byte" / ".quad" / ".tc" / ".localentry" / ".size" / ".type" / ".uleb128" / ".sleb128"
LabelContainingDirectiveName <- ".xword" / ".word" / ".long" / ".set" / ".byte" / ".8byte" / ".4byte" / ".quad" / ".tc" / ".localentry" / ".size" / ".type" / ".uleb128" / ".sleb128"
SymbolArgs <- SymbolArg ((WS? ',' WS?) SymbolArg)*
SymbolArg <- Offset /
SymbolType /
(Offset / LocalSymbol / SymbolName / Dot) WS? Operator WS? (Offset / LocalSymbol / SymbolName) /
LocalSymbol TCMarker? /
SymbolName Offset /
SymbolName TCMarker?
SymbolShift <- ('<<' / '>>') WS? [0-9]+
SymbolArg <- (OpenParen WS?)? (
Offset /
SymbolType /
(Offset / LocalSymbol / SymbolName / Dot) WS? Operator WS? (Offset / LocalSymbol / SymbolName) /
LocalSymbol TCMarker? /
SymbolName Offset /
SymbolName TCMarker?)
(WS? CloseParen)? (WS? SymbolShift)?
OpenParen <- '('
CloseParen <- ')'
SymbolType <- [@%] ('function' / 'object')
Dot <- '.'
TCMarker <- '[TC]'
@ -73,7 +78,7 @@ RegisterOrConstant <- (('%'[[A-Z]][[A-Z0-9]]*) /
ARMRegister)
![fb:(+\-]
ARMConstantTweak <- ("lsl" / "sxtw" / "uxtw" / "uxtb" / "lsr" / "ror" / "asr") (WS '#' Offset)?
ARMRegister <- "sp" / ([xwdqs] [0-9] [0-9]?) / "xzr" / "wzr" / ARMVectorRegister / ('{' WS? ARMVectorRegister (',' WS? ARMVectorRegister)* WS? '}' ('[' [0-9] ']')? )
ARMRegister <- "sp" / ([xwdqs] [0-9] [0-9]?) / "xzr" / "wzr" / ARMVectorRegister / ('{' WS? ARMVectorRegister (',' WS? ARMVectorRegister)* WS? '}' ('[' [0-9] [0-9]? ']')? )
ARMVectorRegister <- "v" [0-9] [0-9]? ('.' [0-9]* [bsdhq] ('[' [0-9] [0-9]? ']')? )?
# Compilers only output a very limited number of expression forms. Rather than
# implement a full expression parser, this enumerate those forms plus a few

File diff suppressed because it is too large Load Diff

@ -43,6 +43,10 @@ foo:
bl bss_symbol_bss_get
# Regression test for a two-digit index.
ld1 { v1.b }[10], [x9]
local_function:
// BSS data

@ -88,6 +88,10 @@ foo:
bl bss_symbol_bss_get
# Regression test for a two-digit index.
ld1 { v1.b }[10], [x9]
.Llocal_function_local_target:
local_function:

@ -12,3 +12,8 @@
.uleb128 .L2-.L1
.sleb128 .L2-.L1
# .byte was not parsed as a symbol-containing directive on the
# assumption that it's too small to hold a pointer. But Clang
# will store offsets in it.
.byte (.LBB231_40-.LBB231_19)>>2, 4, .Lfoo, (.Lfoo), .Lfoo<<400, ( .Lfoo ) << 66
.byte 421

@ -89,6 +89,12 @@ bar:
# WAS .sleb128 .L2-.L1
.sleb128 .L2_BCM_1-.L1_BCM_1
# .byte was not parsed as a symbol-containing directive on the
# assumption that it's too small to hold a pointer. But Clang
# will store offsets in it.
# WAS .byte (.LBB231_40-.LBB231_19)>>2, 4, .Lfoo, (.Lfoo), .Lfoo<<400, ( .Lfoo ) << 66
.byte (.LBB231_40_BCM_1-.LBB231_19_BCM_1)>>2, 4, .Lfoo_BCM_1, (.Lfoo_BCM_1), .Lfoo_BCM_1<<400, ( .Lfoo_BCM_1 ) << 66
.byte 421
.text
.loc 1 2 0
BORINGSSL_bcm_text_end:

Loading…
Cancel
Save