[ELF][MIPS] Do not create dynamic relocations against _gp_disp symbol

MIPS _gp_disp designates offset between start of function and gp pointer
into GOT therefore any relocations against it do not require dynamic
relocation.

llvm-svn: 257492
This commit is contained in:
Simon Atanasyan
2016-01-12 17:31:45 +00:00
parent 6002e78a06
commit 3a5b6e2750
2 changed files with 19 additions and 8 deletions

View File

@@ -287,14 +287,21 @@ void Writer<ELFT>::scanRelocs(
continue;
}
if (Config->EMachine == EM_MIPS && NeedsGot) {
// MIPS ABI has special rules to process GOT entries
// and doesn't require relocation entries for them.
// See "Global Offset Table" in Chapter 5 in the following document
// for detailed description:
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
Body->setUsedInDynamicReloc();
continue;
if (Config->EMachine == EM_MIPS) {
if (NeedsGot) {
// MIPS ABI has special rules to process GOT entries
// and doesn't require relocation entries for them.
// See "Global Offset Table" in Chapter 5 in the following document
// for detailed description:
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
Body->setUsedInDynamicReloc();
continue;
}
if (Body == Config->MipsGpDisp)
// MIPS _gp_disp designates offset between start of function and gp
// pointer into GOT therefore any relocations against it do not require
// dynamic relocation.
continue;
}
// Here we are creating a relocation for the dynamic linker based on

View File

@@ -7,6 +7,7 @@
# RUN: llvm-readobj -symbols %S/Inputs/mips-gp-disp.so \
# RUN: | FileCheck -check-prefix=EXT-SO %s
# RUN: llvm-objdump -d -t %t.so | FileCheck -check-prefix=DIS %s
# RUN: llvm-readobj -relocations %t.so | FileCheck -check-prefix=REL %s
# REQUIRES: mips
@@ -22,6 +23,9 @@
# ^-- 0x37ff0 & 0xffff
# DIS: 00027ff0 *ABS* 00000000 _gp
# REL: Relocations [
# REL-NEXT: ]
.text
.globl __start
__start: