Skip to content

Commit

Permalink
[AsmPrinter] __patchable_function_entries: Set SHF_LINK_ORDER for bin…
Browse files Browse the repository at this point in the history
…utils 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.
  • Loading branch information
MaskRay committed Feb 6, 2021
1 parent 801d9cc commit 853a264
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions llvm/test/CodeGen/AArch64/patchable-function-entry.ll
Original file line number Diff line number Diff line change
@@ -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" {
Expand Down

0 comments on commit 853a264

Please sign in to comment.