[lld] b9efbed - Revert "Move HIP fatbin sections farther away from .text"

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 26 21:14:55 PST 2025


Author: Fangrui Song
Date: 2025-01-26T21:14:49-08:00
New Revision: b9efbed468ec18044070eea936c694fb8f6e244b

URL: https://github.com/llvm/llvm-project/commit/b9efbed468ec18044070eea936c694fb8f6e244b
DIFF: https://github.com/llvm/llvm-project/commit/b9efbed468ec18044070eea936c694fb8f6e244b.diff

LOG: Revert "Move HIP fatbin sections farther away from .text"

This reverts commit 048f35037779763963c4b4478a0884e828ea9538.
This reverts commit f7bbc40b0736cc417f57cd039b098b504cf6a71f.

Related to #95949. A developer with no prior lld contribution and very
little AMD contribution sneaked in these application-specific section
order rules we discourage.

Added: 
    

Modified: 
    lld/ELF/Writer.cpp

Removed: 
    lld/test/ELF/hip-section-layout.s


################################################################################
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 4b75137a5db218..6b34f87f0b8d01 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -650,7 +650,6 @@ static bool isRelroSection(Ctx &ctx, const OutputSection *sec) {
 enum RankFlags {
   RF_NOT_ADDR_SET = 1 << 27,
   RF_NOT_ALLOC = 1 << 26,
-  RF_HIP_FATBIN = 1 << 19,
   RF_PARTITION = 1 << 18, // Partition number (8 bits)
   RF_LARGE_ALT = 1 << 15,
   RF_WRITE = 1 << 14,
@@ -748,15 +747,6 @@ unsigned elf::getSectionRank(Ctx &ctx, OutputSection &osec) {
   if (osec.type == SHT_NOBITS)
     rank |= RF_BSS;
 
-  // Put HIP fatbin related sections further away to avoid wasting relocation
-  // range to jump over them.  Make sure .hip_fatbin is the furthest.
-  if (osec.name == ".hipFatBinSegment")
-    rank |= RF_HIP_FATBIN;
-  if (osec.name == ".hip_gpubin_handle")
-    rank |= RF_HIP_FATBIN | 2;
-  if (osec.name == ".hip_fatbin")
-    rank |= RF_HIP_FATBIN | RF_WRITE | 3;
-
   // Some architectures have additional ordering restrictions for sections
   // within the same PT_LOAD.
   if (ctx.arg.emachine == EM_PPC64) {

diff  --git a/lld/test/ELF/hip-section-layout.s b/lld/test/ELF/hip-section-layout.s
deleted file mode 100644
index b76141c6b41aec..00000000000000
--- a/lld/test/ELF/hip-section-layout.s
+++ /dev/null
@@ -1,41 +0,0 @@
-# REQUIRES: x86
-## Test HIP specific sections layout.
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux --defsym=HIP_SECTIONS=1 --defsym=NON_HIP_SECTIONS=1 %s -o %t.o
-# RUN: ld.lld %t.o -o %t.out
-# RUN: llvm-readobj --sections %t.out | FileCheck %s
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux --defsym=NON_HIP_SECTIONS=1 %s -o %t.1.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux --defsym=HIP_SECTIONS=1 %s -o %t.2.o
-# RUN: ld.lld %t.1.o %t.2.o -o %t.1.s.out
-# RUN: llvm-readobj --sections %t.1.s.out | FileCheck %s
-# RUN: ld.lld %t.2.o %t.1.o -o %t.2.s.out
-# RUN: llvm-readobj --sections %t.2.s.out | FileCheck %s
-
-.ifdef HIP_SECTIONS
-.section .hipFatBinSegment,"aw", at progbits; .space 1
-.section .hip_gpubin_handle,"aw", at progbits; .space 1
-.section .hip_fatbin,"a", at progbits; .space 1
-.endif
-
-.ifdef NON_HIP_SECTIONS
-.global _start
-.text
-_start:
-.section .bss,"aw", at nobits; .space 1
-.section .debug_info,"", at progbits
-.section .debug_line,"", at progbits
-.section .debug_str,"MS", at progbits,1
-.endif
-
-# Check that the HIP sections are placed towards the end but before non allocated sections
-
-// CHECK: Name: .text
-// CHECK: Name: .bss
-// CHECK: Name: .hipFatBinSegment
-// CHECK: Name: .hip_gpubin_handle
-// CHECK: Name: .hip_fatbin
-// CHECK: Name: .debug_info
-// CHECK: Name: .debug_line
-// CHECK: Name: .debug_str
-


        


More information about the llvm-commits mailing list