Produce ELF::R_386_GOTPC relocations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-10-18 18:36:12 +00:00
parent 01b58f637c
commit aa85c21633
3 changed files with 18 additions and 1 deletions

View File

@ -707,7 +707,12 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
break;
}
break;
case FK_Data_4: Type = ELF::R_386_32; break;
case FK_Data_4:
if (Symbol->getName() == "_GLOBAL_OFFSET_TABLE_")
Type = ELF::R_386_GOTPC;
else
Type = ELF::R_386_32;
break;
case FK_Data_2: Type = ELF::R_386_16; break;
case X86::reloc_pcrel_1byte:
case FK_Data_1: Type = ELF::R_386_8; break;

View File

@ -72,6 +72,11 @@ static unsigned getRelaxedOpcode(unsigned Op) {
default:
return Op;
// This is used on i386 with things like addl $foo, %ebx
// FIXME: Should the other *i8 instructions be here too? If not, it might
// be better to just select X86::ADD32ri instead of X86::ADD32ri8.
case X86::ADD32ri8: return X86::ADD32ri;
case X86::JAE_1: return X86::JAE_4;
case X86::JA_1: return X86::JA_4;
case X86::JBE_1: return X86::JBE_4;

View File

@ -16,6 +16,12 @@
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 4)
// CHECK-NEXT: ),
// CHECK-NEXT: # Relocation 2
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 10)
// CHECK-NEXT: ),
.text
bar:
@ -24,6 +30,7 @@ bar:
.global bar2
bar2:
calll bar2@PLT
addl $_GLOBAL_OFFSET_TABLE_, %ebx
.section .rodata.str1.16,"aMS",@progbits,1
.Lfoo: