[llvm] 853a264 - [AsmPrinter] __patchable_function_entries: Set SHF_LINK_ORDER for binutils 2.36 and above
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 19:53:13 PST 2021
Author: Fangrui Song
Date: 2021-02-05T19:53:06-08:00
New Revision: 853a2649160c1c80b9bbd38a20b53ca8fab704e8
URL: https://github.com/llvm/llvm-project/commit/853a2649160c1c80b9bbd38a20b53ca8fab704e8
DIFF: https://github.com/llvm/llvm-project/commit/853a2649160c1c80b9bbd38a20b53ca8fab704e8.diff
LOG: [AsmPrinter] __patchable_function_entries: Set SHF_LINK_ORDER for binutils 2.36 and above
This matches GCC behavior when the configure-time binutils is new. GNU ld<2.36
did not support mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections in an
output section, so we conservatively disable SHF_LINK_ORDER for <2.36.
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 b6f100984492..c2e2a4f7695d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3464,9 +3464,9 @@ void AsmPrinter::emitPatchableFunctionEntries() {
const MCSymbolELF *LinkedToSym = nullptr;
StringRef GroupName;
- // GNU as < 2.35 did not support section flag 'o'. Use SHF_LINK_ORDER only
- // if we are using the integrated assembler.
- if (MAI->useIntegratedAssembler()) {
+ // GNU as < 2.35 did not support section flag 'o'. GNU ld < 2.36 did not
+ // support mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections.
+ if (MAI->useIntegratedAssembler() || MAI->binutilsIsAtLeast(2, 36)) {
Flags |= ELF::SHF_LINK_ORDER;
if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP;
diff --git a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
index 2d5615678d8c..776890639ec6 100644
--- a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
@@ -1,8 +1,10 @@
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
; RUN: llc -mtriple=aarch64 -function-sections %s -o - | FileCheck %s
-; RUN: llc -mtriple=aarch64 -no-integrated-as %s -o - | FileCheck --check-prefix=NOLINK %s
+; RUN: llc -mtriple=aarch64 -function-sections %s -o - | FileCheck %s
+; RUN: llc -mtriple=aarch64 -no-integrated-as -binutils-version=2.35 %s -o - | FileCheck --check-prefix=NOLINK %s
+; RUN: llc -mtriple=aarch64 -no-integrated-as -binutils-version=2.36 %s -o - | FileCheck %s
-;; GNU as < 2.35 did not support section flag 'o'.
+;; GNU ld < 2.36 did not support mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections.
; NOLINK-NOT: "awo"
define i32 @f0() "patchable-function-entry"="0" {
More information about the llvm-commits
mailing list