[PATCH] D15740: [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 Jan 20 12:38:34 PST 2016


atanasyan updated the summary for this revision.
atanasyan updated this revision to Diff 45422.
atanasyan added a comment.
Herald added a reviewer: vkalintiris.

I implemented support for target specific ELF section flags in a separate commit r258334. Now this patch contains MIPS specific code only.


Repository:
  rL LLVM

http://reviews.llvm.org/D15740

Files:
  lib/Target/Mips/MipsTargetObjectFile.cpp
  test/CodeGen/Mips/mips-shf-gprel.ll

Index: test/CodeGen/Mips/mips-shf-gprel.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/mips-shf-gprel.ll
@@ -0,0 +1,15 @@
+; 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 data = global [4 x i32] [i32 1, i32 2, i32 3, i32 4], 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: ]
Index: lib/Target/Mips/MipsTargetObjectFile.cpp
===================================================================
--- lib/Target/Mips/MipsTargetObjectFile.cpp
+++ lib/Target/Mips/MipsTargetObjectFile.cpp
@@ -41,10 +41,12 @@
   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);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15740.45422.patch
Type: text/x-patch
Size: 1559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160120/e88e2058/attachment.bin>


More information about the llvm-commits mailing list