mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:19:43 +00:00
[TargetLoweringObjectFileImpl] Make .llvmbc and .llvmcmd non-SHF_ALLOC
There are two ways .llvmbc can be produced: * clang -c -fembed-bitcode=all (which also produces .llvmcmd) * LTO backend: ld.lld -mllvm -lto-embed-bitcode or -plugin-opt=-lto-embed-bitcode .llvmbc and .llvmcmd have the SHF_ALLOC flag, so they can be dropped by --gc-sections. This patch sets SectionKind::Metadata to drop the SHF_ALLOC flag. This is conceptually correct: the two sections are not part of the process image, so SHF_ALLOC is not appropriate. `test/LTO/X86/embed-bitcode.ll`: changed `llvm-objcopy -O binary --only-section` to `llvm-objcopy --dump-section`. `-O binary` does not dump non-SHF_ALLOC sections. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D86374
This commit is contained in:
parent
d984833f21
commit
0c234a7fc0
@ -436,7 +436,8 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
|
|||||||
if (Name == getInstrProfSectionName(IPSK_covmap, Triple::ELF,
|
if (Name == getInstrProfSectionName(IPSK_covmap, Triple::ELF,
|
||||||
/*AddSegmentInfo=*/false) ||
|
/*AddSegmentInfo=*/false) ||
|
||||||
Name == getInstrProfSectionName(IPSK_covfun, Triple::ELF,
|
Name == getInstrProfSectionName(IPSK_covfun, Triple::ELF,
|
||||||
/*AddSegmentInfo=*/false))
|
/*AddSegmentInfo=*/false) ||
|
||||||
|
Name == ".llvmbc" || Name == ".llvmcmd")
|
||||||
return SectionKind::getMetadata();
|
return SectionKind::getMetadata();
|
||||||
|
|
||||||
if (Name.empty() || Name[0] != '.') return K;
|
if (Name.empty() || Name[0] != '.') return K;
|
||||||
|
10
test/CodeGen/X86/embed-bitcode.ll
Normal file
10
test/CodeGen/X86/embed-bitcode.ll
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
; RUN: llc -filetype=obj -mtriple=x86_64 %s -o %t
|
||||||
|
; RUN: llvm-readelf -S %t | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: .text PROGBITS 0000000000000000 [[#%x,OFF:]] 000000 00 AX 0
|
||||||
|
; CHECK-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] 000004 00 0
|
||||||
|
; CHECK-NEXT: .llvmcmd PROGBITS 0000000000000000 [[#%x,OFF:]] 000005 00 0
|
||||||
|
|
||||||
|
@llvm.embedded.module = private constant [4 x i8] c"BC\C0\DE", section ".llvmbc"
|
||||||
|
@llvm.cmdline = private constant [5 x i8] c"-cc1\00", section ".llvmcmd"
|
||||||
|
@llvm.compiler.used = appending global [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @llvm.embedded.module, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @llvm.cmdline, i32 0, i32 0)], section "llvm.metadata"
|
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode -o %t3 %t1.o %t2.o %t3.o
|
; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode -o %t3 %t1.o %t2.o %t3.o
|
||||||
; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
|
; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
|
||||||
; RUN: llvm-objcopy -O binary -j .llvmbc %t3.0 %t-embedded.bc
|
; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
|
||||||
; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefix=CHECK-LL
|
; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefix=CHECK-LL
|
||||||
|
|
||||||
; CHECK-ELF: .text
|
; CHECK-ELF: .text PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
|
||||||
; CHECK-ELF: .llvmbc
|
; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 0
|
||||||
|
|
||||||
; CHECK-LL: @_start
|
; CHECK-LL: @_start
|
||||||
; CHECK-LL: @foo
|
; CHECK-LL: @foo
|
||||||
|
Loading…
Reference in New Issue
Block a user