diff options
author | Akira Hatanaka <ahatanaka@mips.com> | 2011-12-13 02:27:40 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@mips.com> | 2011-12-13 02:27:40 +0000 |
commit | f3315cf65f9574cd1e4e784d2860c943cfa65ce9 (patch) | |
tree | d58fa6b8942c4eb05ac0a7d9ec6747e7d0a04a34 | |
parent | 6f20c61e07b570ad95fec81437972d653b362e63 (diff) | |
download | llvm-f3315cf65f9574cd1e4e784d2860c943cfa65ce9.tar.gz llvm-f3315cf65f9574cd1e4e784d2860c943cfa65ce9.tar.bz2 llvm-f3315cf65f9574cd1e4e784d2860c943cfa65ce9.tar.xz |
Relocation against a symbol, instead of against section. We had some extreme
test cases where there were a lot of relocations applied relative to a large
rodata section. Gas would create a symbol for each of these whereas we would
be relative to the beginning of the rodata section. This change mimics what
gas does.
Patch by Jack Carter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146468 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/Mips/DO-relsym.ll | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 40b84ae458..92aad94f17 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -1851,7 +1851,8 @@ const MCSymbol *MipsELFObjectWriter::ExplicitRelSym(const MCAssembler &Asm, assert(Target.getSymA() && "SymA cannot be 0."); const MCSymbol &Sym = Target.getSymA()->getSymbol(); - if (Sym.getSection().getKind().isMergeable1ByteCString()) + if (Sym.getSection().getKind().isMergeableCString() || + Sym.getSection().getKind().isMergeableConst()) return &Sym; return NULL; @@ -1914,4 +1915,3 @@ unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target, return Type; } - diff --git a/test/CodeGen/Mips/DO-relsym.ll b/test/CodeGen/Mips/DO-relsym.ll new file mode 100644 index 0000000000..0f74437ec5 --- /dev/null +++ b/test/CodeGen/Mips/DO-relsym.ll @@ -0,0 +1,29 @@ +; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux %s -o - | elf-dump --dump-section-data | FileCheck %s + +; Check that the appropriate symbols were created. + +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$.str' +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$.str1' +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$CPI0_0' +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$CPI0_1' + +@.str = private unnamed_addr constant [6 x i8] c"abcde\00", align 1 +@gc1 = external global i8* +@.str1 = private unnamed_addr constant [5 x i8] c"fghi\00", align 1 +@gc2 = external global i8* +@gd1 = external global double +@gd2 = external global double + +define void @foo1() nounwind { +entry: + store i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i8** @gc1, align 4 + store i8* getelementptr inbounds ([5 x i8]* @.str1, i32 0, i32 0), i8** @gc2, align 4 + %0 = load double* @gd1, align 8 + %add = fadd double %0, 2.500000e+00 + store double %add, double* @gd1, align 8 + %1 = load double* @gd2, align 8 + %add1 = fadd double %1, 4.500000e+00 + store double %add1, double* @gd2, align 8 + ret void +} + |