-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LoongArch] Use R_LARCH_ALIGN with section symbol #84741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# REQUIRES: loongarch | ||
SixWeining marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Test `ld -r` not changes the addend of R_LARCH_ALIGN. | ||
|
||
# RUN: llvm-mc --filetype=obj --triple=loongarch64 --mattr=+relax %s -o %t.64.o | ||
# RUN: ld.lld -r %t.64.o %t.64.o -o %t.64.r | ||
# RUN: llvm-objdump -dr --no-show-raw-insn %t.64.r | FileCheck %s | ||
|
||
# CHECK: <.text>: | ||
# CHECK-NEXT: break 1 | ||
# CHECK-NEXT: nop | ||
# CHECK-NEXT: {{0*}}04: R_LARCH_ALIGN .text+0x804 | ||
# CHECK-NEXT: nop | ||
# CHECK-NEXT: nop | ||
# CHECK-NEXT: break 2 | ||
# CHECK-NEXT: break 0 | ||
# CHECK-NEXT: break 0 | ||
# CHECK-NEXT: break 0 | ||
# CHECK-NEXT: break 1 | ||
# CHECK-NEXT: nop | ||
# CHECK-NEXT: {{0*}}24: R_LARCH_ALIGN .text+0x804 | ||
# CHECK-NEXT: nop | ||
# CHECK-NEXT: nop | ||
# CHECK-NEXT: break 2 | ||
|
||
.text | ||
break 1 | ||
.p2align 4, , 8 | ||
break 2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,11 +226,8 @@ bool LoongArchAsmBackend::shouldInsertFixupForCodeAlign( | |
MCFixup::create(0, Dummy, MCFixupKind(LoongArch::fixup_loongarch_align)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lld is not coupled with MC. Changes to both places are usually done in two patches. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But |
||
const MCSymbolRefExpr *MCSym = getSecToAlignSym()[Sec]; | ||
if (MCSym == nullptr) { | ||
// Create a symbol and make the value of symbol is zero. | ||
MCSymbol *Sym = Ctx.createNamedTempSymbol("la-relax-align"); | ||
Sym->setFragment(&*Sec->getBeginSymbol()->getFragment()); | ||
Asm.registerSymbol(*Sym); | ||
MCSym = MCSymbolRefExpr::create(Sym, Ctx); | ||
// Use section symbol directly. | ||
MCSym = MCSymbolRefExpr::create(Sec->getBeginSymbol(), Ctx); | ||
getSecToAlignSym()[Sec] = MCSym; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am more convinced that the generic function should be moved to Arch/ as I did for
relocateAlloc
. You might not be interested in doing such generic improvement. I'll investigate it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it will go next if condition and do something wrong.