Skip to content

[PAC][MC][AArch64] Fix error message for AUTH_ABS64 reloc with ILP32 #89563

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

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,18 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
Target.getAccessVariant() == MCSymbolRefExpr::VK_GOTPCREL)
? ELF::R_AARCH64_GOTPCREL32
: R_CLS(ABS32);
case FK_Data_8:
case FK_Data_8: {
bool IsAuth = (RefKind == AArch64MCExpr::VK_AUTH ||
RefKind == AArch64MCExpr::VK_AUTHADDR);
if (IsILP32) {
Ctx.reportError(Fixup.getLoc(),
"ILP32 8 byte absolute data "
"relocation not supported (LP64 eqv: ABS64)");
Twine("ILP32 8 byte absolute data "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8-byte absolute data relocation is not supported in ILP32?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the spec, it's not - see no "ELF32 code" for R_<CLS>_ABS64 in the table here https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#static-data-relocations

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I was suggesting a candidate diagnostic message

8-byte absolute data relocation is not supported in ILP32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that error messages across the function use some convention, so it's probably better to stick with it (or change the messages everywhere at once)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think we should get rid of these LP64 eqv: messages because of the maintenance burden and because they're not really helpful. If you're targeting ILP32 and writing assembly that triggers one of these messages then you're probably an expert who doesn't need help figuring out which relocation type to use, and knowing the LP64 equivalent wouldn't help you anyway because you'd need something that works on ILP32.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"relocation not supported (LP64 eqv: ") +
(IsAuth ? "AUTH_ABS64" : "ABS64") + Twine(')'));
return ELF::R_AARCH64_NONE;
} else {
if (RefKind == AArch64MCExpr::VK_AUTH ||
RefKind == AArch64MCExpr::VK_AUTHADDR)
return ELF::R_AARCH64_AUTH_ABS64;
return ELF::R_AARCH64_ABS64;
}
return (IsAuth ? ELF::R_AARCH64_AUTH_ABS64 : ELF::R_AARCH64_ABS64);
}
case AArch64::fixup_aarch64_add_imm12:
if (RefKind == AArch64MCExpr::VK_DTPREL_HI12)
return R_CLS(TLSLD_ADD_DTPREL_HI12);
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/MC/AArch64/ilp32-diagnostics.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

.xword sym+16
// CHECK-ERROR: error: ILP32 8 byte absolute data relocation not supported (LP64 eqv: ABS64)
// CHECK-ERROR: ^

.xword sym@AUTH(da,42)
// CHECK-ERROR: error: ILP32 8 byte absolute data relocation not supported (LP64 eqv: AUTH_ABS64)
// CHECK-ERROR: ^

.xword sym@AUTH(da,42,addr)
// CHECK-ERROR: error: ILP32 8 byte absolute data relocation not supported (LP64 eqv: AUTH_ABS64)
// CHECK-ERROR: ^

movz x7, #:abs_g3:some_label
Expand Down