[llvm] r259641 - [mips] Add SHF_MIPS_GPREL flag to the MIPS .sbss and .sdata sections
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 3 03:50:22 PST 2016
Author: atanasyan
Date: Wed Feb 3 05:50:22 2016
New Revision: 259641
URL: http://llvm.org/viewvc/llvm-project?rev=259641&view=rev
Log:
[mips] Add SHF_MIPS_GPREL flag to the MIPS .sbss and .sdata sections
MIPS ABI states that .sbss and .sdata sections must have SHF_MIPS_GPREL
flag. See Figure 4–7 on page 69 in the following document:
ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf.
Differential Revision: http://reviews.llvm.org/D15740
Added:
llvm/trunk/test/CodeGen/Mips/mips-shf-gprel.ll
Modified:
llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp?rev=259641&r1=259640&r2=259641&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp Wed Feb 3 05:50:22 2016
@@ -41,10 +41,12 @@ void MipsTargetObjectFile::Initialize(MC
InitializeELF(TM.Options.UseInitArray);
SmallDataSection = getContext().getELFSection(
- ".sdata", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
+ ".sdata", ELF::SHT_PROGBITS,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_MIPS_GPREL);
SmallBSSSection = getContext().getELFSection(".sbss", ELF::SHT_NOBITS,
- ELF::SHF_WRITE | ELF::SHF_ALLOC);
+ ELF::SHF_WRITE | ELF::SHF_ALLOC |
+ ELF::SHF_MIPS_GPREL);
this->TM = &static_cast<const MipsTargetMachine &>(TM);
}
Added: llvm/trunk/test/CodeGen/Mips/mips-shf-gprel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips-shf-gprel.ll?rev=259641&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/mips-shf-gprel.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/mips-shf-gprel.ll Wed Feb 3 05:50:22 2016
@@ -0,0 +1,24 @@
+; Check that .sdata section has SHF_MIPS_GPREL flag.
+
+; RUN: llc -mips-ssection-threshold=16 -mgpopt -mattr=noabicalls \
+; RUN: -relocation-model=static -march=mips -o - %s -filetype=obj \
+; RUN: | llvm-readobj -s | FileCheck %s
+
+ at data1 = global [4 x i32] [i32 1, i32 2, i32 3, i32 4], align 4
+ at date2 = global [4 x i32] zeroinitializer, align 4
+
+; CHECK: Name: .sdata
+; CHECK-NEXT: Type: SHT_PROGBITS
+; CHECK-NEXT: Flags [ (0x10000003)
+; CHECK-NEXT: SHF_ALLOC
+; CHECK-NEXT: SHF_MIPS_GPREL
+; CHECK-NEXT: SHF_WRITE
+; CHECK-NEXT: ]
+
+; CHECK: Name: .sbss
+; CHECK-NEXT: Type: SHT_NOBITS
+; CHECK-NEXT: Flags [ (0x10000003)
+; CHECK-NEXT: SHF_ALLOC
+; CHECK-NEXT: SHF_MIPS_GPREL
+; CHECK-NEXT: SHF_WRITE
+; CHECK-NEXT: ]
More information about the llvm-commits
mailing list