[lld] r209644 - [Mips] Handle relocations against __gnu_local_gp symbol.
Simon Atanasyan
simon at atanasyan.com
Mon May 26 22:23:17 PDT 2014
Author: atanasyan
Date: Tue May 27 00:23:16 2014
New Revision: 209644
URL: http://llvm.org/viewvc/llvm-project?rev=209644&view=rev
Log:
[Mips] Handle relocations against __gnu_local_gp symbol.
Added:
lld/trunk/test/elf/Mips/gp-sym-1.test
lld/trunk/test/elf/Mips/gp-sym-2.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
lld/trunk/test/elf/Mips/dynlib-fileheader.test
lld/trunk/test/elf/Mips/exe-fileheader.test
lld/trunk/test/elf/Mips/rel-dynamic-01.test
lld/trunk/test/elf/Mips/rel-dynamic-04.test
lld/trunk/test/elf/Mips/rel-dynamic-05.test
lld/trunk/test/elf/Mips/rel-dynamic-08.test
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h Tue May 27 00:23:16 2014
@@ -52,6 +52,7 @@ public:
setAtomValue("_GLOBAL_OFFSET_TABLE_", got);
setAtomValue("_gp", gp);
setAtomValue("_gp_disp", gp);
+ setAtomValue("__gnu_local_gp", gp);
}
bool hasGlobalGOTEntry(const Atom *a) const {
@@ -64,6 +65,7 @@ public:
file->addAbsoluteAtom("_GLOBAL_OFFSET_TABLE_");
file->addAbsoluteAtom("_gp");
file->addAbsoluteAtom("_gp_disp");
+ file->addAbsoluteAtom("__gnu_local_gp");
}
return file;
}
Modified: lld/trunk/test/elf/Mips/dynlib-fileheader.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/dynlib-fileheader.test?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/dynlib-fileheader.test (original)
+++ lld/trunk/test/elf/Mips/dynlib-fileheader.test Tue May 27 00:23:16 2014
@@ -26,7 +26,7 @@
# CHECK: Version: 1
# CHECK: Entry: 0xF0
# CHECK: ProgramHeaderOffset: 0x34
-# CHECK: SectionHeaderOffset: 0x20E0
+# CHECK: SectionHeaderOffset: 0x2100
# CHECK: Flags [ (0x70001007)
# CHECK: EF_MIPS_ABI_O32 (0x1000)
# CHECK: EF_MIPS_ARCH_32R2 (0x70000000)
Modified: lld/trunk/test/elf/Mips/exe-fileheader.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/exe-fileheader.test?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/exe-fileheader.test (original)
+++ lld/trunk/test/elf/Mips/exe-fileheader.test Tue May 27 00:23:16 2014
@@ -31,7 +31,7 @@
# CHECK: Version: 1
# CHECK: Entry: 0x4001A0
# CHECK: ProgramHeaderOffset: 0x34
-# CHECK: SectionHeaderOffset: 0x2268
+# CHECK: SectionHeaderOffset: 0x2288
# CHECK: Flags [ (0x70001005)
# CHECK: EF_MIPS_ABI_O32 (0x1000)
# CHECK: EF_MIPS_ARCH_32R2 (0x70000000)
Added: lld/trunk/test/elf/Mips/gp-sym-1.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/gp-sym-1.test?rev=209644&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/gp-sym-1.test (added)
+++ lld/trunk/test/elf/Mips/gp-sym-1.test Tue May 27 00:23:16 2014
@@ -0,0 +1,59 @@
+# Check that relocations against __gnu_local_gp use "gp" value as target.
+
+# RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-pic.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-pic.o
+# RUN: yaml2obj -format=elf %s > %t.o
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t.o %t.so
+# RUN: llvm-readobj -symbols %t.exe | FileCheck -check-prefix=SYM %s
+# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=SEC %s
+
+# SYM: Name: _gp (203)
+# SYM-NEXT: Value: 0x408FF0
+
+# SEC: Contents of section .text:
+# SEC-NEXT: 4001a0 41000000 f08f0000 64001000 A.......d...
+# SEC: Contents of section .got:
+# SEC-NEXT: 401000 00000000 00000080 ........
+
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [ EF_MIPS_NOREORDER, EF_MIPS_CPIC,
+ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x04
+ Size: 12
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ Info: .text
+ AddressAlign: 0x04
+ Relocations:
+ - Offset: 0x00
+ Symbol: __gnu_local_gp
+ Type: R_MIPS_HI16
+ - Offset: 0x04
+ Symbol: __gnu_local_gp
+ Type: R_MIPS_LO16
+ - Offset: 0x08
+ Symbol: T1
+ Type: R_MIPS_26
+
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ Global:
+ - Name: T0
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x08
+ - Name: __gnu_local_gp
+ - Name: T1
Added: lld/trunk/test/elf/Mips/gp-sym-2.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/gp-sym-2.test?rev=209644&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/gp-sym-2.test (added)
+++ lld/trunk/test/elf/Mips/gp-sym-2.test Tue May 27 00:23:16 2014
@@ -0,0 +1,71 @@
+# Check that R_MIPS32 relocation against __gnu_local_gp causes emitting
+# of R_MIPS_REL32 relocation in case of shared library file linking
+# and does not produce any dynamic relocation in case of linking a non-shared
+# executable file.
+
+# Now the test failed because the __gnu_local_gp symbol becomes defined
+# absolute symbol and we do not generate R_MIPS_REL32 in case of shared
+# library linking.
+# XFAIL: *
+
+# RUN: yaml2obj -format=elf %S/Inputs/pic-obj.yaml > %t-pic.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t-ext.so %t-pic.o
+# RUN: yaml2obj -format=elf %s > %t.o
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t.o %t-ext.so
+# RUN: llvm-readobj -r %t.exe | FileCheck -check-prefix=EXE %s
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.exe %t.o %t-ext.so
+# RUN: llvm-readobj -r %t.exe | FileCheck -check-prefix=SO %s
+
+# EXE: Relocations [
+# EXE-NEXT: ]
+
+# SO: Relocations [
+# SO-NEXT: Section (5) .rel.dyn {
+# SO-NEXT: 0x0 R_MIPS_NONE - 0x0
+# SO-NEXT: 0x2EC R_MIPS_REL32 __gnu_local_gp 0x0
+# SO-NEXT: }
+# SO-NEXT: ]
+
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [ EF_MIPS_NOREORDER, EF_MIPS_CPIC, EF_MIPS_PIC,
+ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x04
+ Size: 12
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ Info: .text
+ AddressAlign: 0x04
+ Relocations:
+ - Offset: 0x00
+ Symbol: __gnu_local_gp
+ Type: R_MIPS_32
+ - Offset: 0x04
+ Symbol: T1
+ Type: R_MIPS_LO16
+ - Offset: 0x08
+ Symbol: T2
+ Type: R_MIPS_CALL16
+
+Symbols:
+ Local:
+ - Name: .text
+ Type: STT_SECTION
+ Section: .text
+ Global:
+ - Name: T0
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x08
+ - Name: __gnu_local_gp
+ - Name: T1
+ - Name: T2
Modified: lld/trunk/test/elf/Mips/rel-dynamic-01.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/rel-dynamic-01.test?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/rel-dynamic-01.test (original)
+++ lld/trunk/test/elf/Mips/rel-dynamic-01.test Tue May 27 00:23:16 2014
@@ -69,7 +69,7 @@
# PLT-SYM-NEXT: Section: .bss (0xD)
# PLT-SYM-NEXT: }
# PLT-SYM-NEXT: Symbol {
-# PLT-SYM-NEXT: Name: T3@ (7)
+# PLT-SYM-NEXT: Name: T3@ (4)
# PLT-SYM-NEXT: Value: 0x0
# PLT-SYM-NEXT: Size: 0
# PLT-SYM-NEXT: Binding: Global (0x1)
@@ -78,7 +78,7 @@
# PLT-SYM-NEXT: Section: Undefined (0x0)
# PLT-SYM-NEXT: }
# PLT-SYM-NEXT: Symbol {
-# PLT-SYM-NEXT: Name: T1@ (10)
+# PLT-SYM-NEXT: Name: T1@ (7)
# PLT-SYM-NEXT: Value: 0x400240
# PLT-SYM-NEXT: Size: 0
# PLT-SYM-NEXT: Binding: Global (0x1)
@@ -96,7 +96,7 @@
# PLT-SYM-NEXT: Section: Undefined (0x0)
# PLT-SYM-NEXT: }
# PLT-SYM-NEXT: Symbol {
-# PLT-SYM-NEXT: Name: T2@ (4)
+# PLT-SYM-NEXT: Name: T2@ (10)
# PLT-SYM-NEXT: Value: 0x0
# PLT-SYM-NEXT: Size: 0
# PLT-SYM-NEXT: Binding: Global (0x1)
Modified: lld/trunk/test/elf/Mips/rel-dynamic-04.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/rel-dynamic-04.test?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/rel-dynamic-04.test (original)
+++ lld/trunk/test/elf/Mips/rel-dynamic-04.test Tue May 27 00:23:16 2014
@@ -86,8 +86,8 @@
# PLT-NEXT: Section: Undefined (0x0)
# PLT-NEXT: }
# PLT-NEXT: Symbol {
-# PLT-NEXT: Name: T2@ (1)
-# PLT-NEXT: Value: 0x4010E0
+# PLT-NEXT: Name: T3@ (1)
+# PLT-NEXT: Value: 0x4010F0
# PLT-NEXT: Size: 0
# PLT-NEXT: Binding: Global (0x1)
# PLT-NEXT: Type: Function (0x2)
@@ -95,8 +95,8 @@
# PLT-NEXT: Section: Undefined (0x0)
# PLT-NEXT: }
# PLT-NEXT: Symbol {
-# PLT-NEXT: Name: T3@ (4)
-# PLT-NEXT: Value: 0x4010F0
+# PLT-NEXT: Name: T2@ (7)
+# PLT-NEXT: Value: 0x4010E0
# PLT-NEXT: Size: 0
# PLT-NEXT: Binding: Global (0x1)
# PLT-NEXT: Type: Function (0x2)
@@ -104,7 +104,7 @@
# PLT-NEXT: Section: Undefined (0x0)
# PLT-NEXT: }
# PLT-NEXT: Symbol {
-# PLT-NEXT: Name: T1@ (7)
+# PLT-NEXT: Name: T1@ (4)
# PLT-NEXT: Value: 0x0
# PLT-NEXT: Size: 0
# PLT-NEXT: Binding: Global (0x1)
Modified: lld/trunk/test/elf/Mips/rel-dynamic-05.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/rel-dynamic-05.test?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/rel-dynamic-05.test (original)
+++ lld/trunk/test/elf/Mips/rel-dynamic-05.test Tue May 27 00:23:16 2014
@@ -68,8 +68,8 @@
# PLT-NEXT: Section: Undefined (0x0)
# PLT-NEXT: }
# PLT-NEXT: Symbol {
-# PLT-NEXT: Name: T2@ (1)
-# PLT-NEXT: Value: 0x4001F0
+# PLT-NEXT: Name: T3@ (1)
+# PLT-NEXT: Value: 0x400200
# PLT-NEXT: Size: 0
# PLT-NEXT: Binding: Global (0x1)
# PLT-NEXT: Type: Function (0x2)
@@ -77,8 +77,8 @@
# PLT-NEXT: Section: Undefined (0x0)
# PLT-NEXT: }
# PLT-NEXT: Symbol {
-# PLT-NEXT: Name: T3@ (4)
-# PLT-NEXT: Value: 0x400200
+# PLT-NEXT: Name: T1@ (4)
+# PLT-NEXT: Value: 0x4001E0
# PLT-NEXT: Size: 0
# PLT-NEXT: Binding: Global (0x1)
# PLT-NEXT: Type: Function (0x2)
@@ -86,8 +86,8 @@
# PLT-NEXT: Section: Undefined (0x0)
# PLT-NEXT: }
# PLT-NEXT: Symbol {
-# PLT-NEXT: Name: T1@ (7)
-# PLT-NEXT: Value: 0x4001E0
+# PLT-NEXT: Name: T2@ (7)
+# PLT-NEXT: Value: 0x4001F0
# PLT-NEXT: Size: 0
# PLT-NEXT: Binding: Global (0x1)
# PLT-NEXT: Type: Function (0x2)
Modified: lld/trunk/test/elf/Mips/rel-dynamic-08.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/rel-dynamic-08.test?rev=209644&r1=209643&r2=209644&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/rel-dynamic-08.test (original)
+++ lld/trunk/test/elf/Mips/rel-dynamic-08.test Tue May 27 00:23:16 2014
@@ -45,7 +45,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: T1@ (4)
+# CHECK-NEXT: Name: T1@ (1)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
@@ -54,7 +54,7 @@
# CHECK-NEXT: Section: Undefined (0x0)
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
-# CHECK-NEXT: Name: T2@ (1)
+# CHECK-NEXT: Name: T2@ (4)
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global (0x1)
More information about the llvm-commits
mailing list