Support medium memory models.
With `-mcmodel=medium`, Clang may emit loads of the GOT address. Delocate needs to handle that in order to avoid a relocation inside the module. Bug: b:316210772 Change-Id: I55eb2711860e43f68de131e28538aef9f5ce1889 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64791 Auto-Submit: Adam Langley <agl@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com>
This commit is contained in:
committed by
Boringssl LUCI CQ
parent
b251d813ec
commit
7460d74564
@@ -1163,6 +1163,22 @@ Args:
|
||||
|
||||
args = append(args, argStr)
|
||||
|
||||
case ruleGOTAddress:
|
||||
if instructionName != "leaq" {
|
||||
return nil, fmt.Errorf("_GLOBAL_OFFSET_TABLE_ used outside of lea")
|
||||
}
|
||||
if i != 0 || len(argNodes) != 2 {
|
||||
return nil, fmt.Errorf("Load of _GLOBAL_OFFSET_TABLE_ address didn't have expected form")
|
||||
}
|
||||
d.gotDeltaNeeded = true
|
||||
changed = true
|
||||
targetReg := d.contents(argNodes[1])
|
||||
args = append(args, ".Lboringssl_got_delta(%rip)")
|
||||
wrappers = append(wrappers, func(k func()) {
|
||||
k()
|
||||
d.output.WriteString(fmt.Sprintf("\taddq .Lboringssl_got_delta(%%rip), %s\n", targetReg))
|
||||
})
|
||||
|
||||
case ruleGOTLocation:
|
||||
if instructionName != "movabsq" {
|
||||
return nil, fmt.Errorf("_GLOBAL_OFFSET_TABLE_ lookup didn't use movabsq")
|
||||
|
||||
@@ -68,8 +68,9 @@ LocalLabel <- [0-9][0-9$]*
|
||||
LocalLabelRef <- [0-9][0-9$]*[bf]
|
||||
Instruction <- InstructionName (WS InstructionArg ((WS? ',' WS?) InstructionArg)*)?
|
||||
InstructionName <- [[A-Z]][[A-Z.0-9]]* [.+\-]?
|
||||
InstructionArg <- IndirectionIndicator? (ARMConstantTweak / RegisterOrConstant / LocalLabelRef / TOCRefHigh / TOCRefLow / GOTLocation / GOTSymbolOffset / MemoryRef) AVX512Token*
|
||||
InstructionArg <- IndirectionIndicator? (ARMConstantTweak / RegisterOrConstant / LocalLabelRef / TOCRefHigh / TOCRefLow / GOTLocation / GOTAddress / GOTSymbolOffset / MemoryRef) AVX512Token*
|
||||
GOTLocation <- '$_GLOBAL_OFFSET_TABLE_-' LocalSymbol
|
||||
GOTAddress <- '_GLOBAL_OFFSET_TABLE_(%rip)'
|
||||
GOTSymbolOffset <- ('$' SymbolName '@GOT' 'OFF'?) / (":got:" SymbolName)
|
||||
AVX512Token <- WS? '{' '%'? [0-9a-z]* '}'
|
||||
TOCRefHigh <- '.TOC.-' ('0b' / ('.L' [a-zA-Z_0-9]+)) "@ha"
|
||||
|
||||
+1860
-1732
File diff suppressed because it is too large
Load Diff
@@ -65,4 +65,7 @@ bar:
|
||||
cmpq foo@GOTPCREL(%rip), %rax
|
||||
cmpq %rax, foo@GOTPCREL(%rip)
|
||||
|
||||
# With -mcmodel=medium, the code may load the address of the GOT directly.
|
||||
leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
|
||||
|
||||
.comm foobar,64,32
|
||||
|
||||
@@ -268,6 +268,11 @@ bar:
|
||||
popq %rbx
|
||||
leaq 128(%rsp), %rsp
|
||||
|
||||
# With -mcmodel=medium, the code may load the address of the GOT directly.
|
||||
# WAS leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx
|
||||
leaq .Lboringssl_got_delta(%rip), %rcx
|
||||
addq .Lboringssl_got_delta(%rip), %rcx
|
||||
|
||||
.comm foobar,64,32
|
||||
.text
|
||||
.loc 1 2 0
|
||||
@@ -302,6 +307,8 @@ OPENSSL_ia32cap_get:
|
||||
.size OPENSSL_ia32cap_addr_delta, 8
|
||||
OPENSSL_ia32cap_addr_delta:
|
||||
.quad OPENSSL_ia32cap_P-OPENSSL_ia32cap_addr_delta
|
||||
.Lboringssl_got_delta:
|
||||
.quad _GLOBAL_OFFSET_TABLE_-.Lboringssl_got_delta
|
||||
.type BORINGSSL_bcm_text_hash, @object
|
||||
.size BORINGSSL_bcm_text_hash, 32
|
||||
BORINGSSL_bcm_text_hash:
|
||||
|
||||
Reference in New Issue
Block a user