[llvm] 7fa5290 - __patchable_function_entries: don't use linkage field 'unique' with -no-integrated-as
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 12 12:57:25 PST 2020
Author: Fangrui Song
Date: 2020-01-12T12:53:44-08:00
New Revision: 7fa5290d5bd5632d7a36a4ea9f46e81e04fb819e
URL: https://github.com/llvm/llvm-project/commit/7fa5290d5bd5632d7a36a4ea9f46e81e04fb819e
DIFF: https://github.com/llvm/llvm-project/commit/7fa5290d5bd5632d7a36a4ea9f46e81e04fb819e.diff
LOG: __patchable_function_entries: don't use linkage field 'unique' with -no-integrated-as
.section name, "flags"G, @type, GroupName[, linkage]
As of binutils 2.33, linkage cannot be 'unique'. For integrated
assembler, we use both 'o' flag and 'unique' linkage to support
--gc-sections and COMDAT with lld.
https://sourceware.org/ml/binutils/2019-11/msg00266.html
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/AArch64/patchable-function-entry.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 1579646352d6..6f9aa4dd79fd 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3204,26 +3204,29 @@ void AsmPrinter::emitPatchableFunctionEntries() {
const unsigned PointerSize = getPointerSize();
if (TM.getTargetTriple().isOSBinFormatELF()) {
auto Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC;
- std::string GroupName;
- if (F.hasComdat()) {
- Flags |= ELF::SHF_GROUP;
- GroupName = F.getComdat()->getName();
- }
- // As of binutils 2.33, GNU as does not support section flag "o". Use
- // SHF_LINK_ORDER if we are using the integrated assembler.
- MCSymbolELF *Link = MAI->useIntegratedAssembler()
- ? cast<MCSymbolELF>(CurrentFnSym)
- : nullptr;
- if (Link)
+ // As of binutils 2.33, GNU as does not support section flag "o" or linkage
+ // field "unique". Use SHF_LINK_ORDER if we are using the integrated
+ // assembler.
+ if (MAI->useIntegratedAssembler()) {
Flags |= ELF::SHF_LINK_ORDER;
-
- MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM);
- auto R = PatchableFunctionEntryID.try_emplace(
- Section, PatchableFunctionEntryID.size());
- OutStreamer->SwitchSection(OutContext.getELFSection(
- "__patchable_function_entries", ELF::SHT_PROGBITS, Flags, 0, GroupName,
- R.first->second, Link));
+ std::string GroupName;
+ if (F.hasComdat()) {
+ Flags |= ELF::SHF_GROUP;
+ GroupName = F.getComdat()->getName();
+ }
+ MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM);
+ unsigned UniqueID =
+ PatchableFunctionEntryID
+ .try_emplace(Section, PatchableFunctionEntryID.size())
+ .first->second;
+ OutStreamer->SwitchSection(OutContext.getELFSection(
+ "__patchable_function_entries", ELF::SHT_PROGBITS, Flags, 0,
+ GroupName, UniqueID, cast<MCSymbolELF>(CurrentFnSym)));
+ } else {
+ OutStreamer->SwitchSection(OutContext.getELFSection(
+ "__patchable_function_entries", ELF::SHT_PROGBITS, Flags));
+ }
EmitAlignment(Align(PointerSize));
OutStreamer->EmitSymbolValue(CurrentFnBegin, PointerSize);
}
diff --git a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
index d90d42f4917a..12b8a35cb93a 100644
--- a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
@@ -3,6 +3,7 @@
; RUN: llc -mtriple=aarch64 -no-integrated-as %s -o - | FileCheck --check-prefix=NOLINK %s
; NOLINK-NOT: "awo"
+; NOLINK-NOT: ,unique,0
define i32 @f0() "patchable-function-entry"="0" {
; CHECK-LABEL: f0:
More information about the llvm-commits
mailing list