[ELF] Fix split-stack caller with hidden non-split-stack callee

Fix a regression after aabe901d57 (`[ELF] Remove
one redundant computeBinding`): isLocal() does not indicate that the symbol is
originally local. For simplicity, just drop this optimization.
This commit is contained in:
Fangrui Song 2022-01-19 12:25:01 -08:00
parent 438f805145
commit 5bd38a2826
3 changed files with 15 additions and 5 deletions

View File

@ -1181,11 +1181,6 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *buf,
std::vector<Relocation *> morestackCalls; std::vector<Relocation *> morestackCalls;
for (Relocation &rel : relocations) { for (Relocation &rel : relocations) {
// Local symbols can't possibly be cross-calls, and should have been
// resolved long before this line.
if (rel.sym->isLocal())
continue;
// Ignore calls into the split-stack api. // Ignore calls into the split-stack api.
if (rel.sym->getName().startswith("__morestack")) { if (rel.sym->getName().startswith("__morestack")) {
if (rel.sym->getName().equals("__morestack")) if (rel.sym->getName().equals("__morestack"))

View File

@ -6,6 +6,13 @@ non_split:
retq retq
.size non_split,. - non_split .size non_split,. - non_split
.global non_split_hidden
.hidden non_split_hidden
.type non_split_hidden,@function
non_split_hidden:
retq
.size non_split_hidden,. - non_split_hidden
.global non_function_text_symbol .global non_function_text_symbol
non_function_text_symbol: non_function_text_symbol:
.byte 0x01 .byte 0x01

View File

@ -111,5 +111,13 @@ prologue2 non_split r10 0x100
prologue2 non_split r11 0x200 prologue2 non_split r11 0x200
# CHECK: <prologue2_calls_non_split_hiddenr11>:
# CHECK-NEXT: lea{{.*}} -16896(%rsp),{{.*}}%r11
# CHECK: cmp{{.*}}%fs:{{[^,]*}},{{.*}}%r11
# CHECK: jae{{.*$}}
# CHECK-NEXT: callq{{.*}}<__morestack_non_split>
prologue2 non_split_hidden r11 0x200
.section .note.GNU-stack,"",@progbits .section .note.GNU-stack,"",@progbits
.section .note.GNU-split-stack,"",@progbits .section .note.GNU-split-stack,"",@progbits