mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
Teach libObject about some more ELF relocations. llvm-objdump -r now knows
every relocation in C++ hello world built with debug info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163271 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
408853ea16
commit
033d182589
@ -1711,15 +1711,15 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
int64_t addend = 0;
|
int64_t addend = 0;
|
||||||
uint16_t symbol_index = 0;
|
uint16_t symbol_index = 0;
|
||||||
switch (sec->sh_type) {
|
switch (sec->sh_type) {
|
||||||
default :
|
default:
|
||||||
return object_error::parse_failed;
|
return object_error::parse_failed;
|
||||||
case ELF::SHT_REL : {
|
case ELF::SHT_REL: {
|
||||||
type = getRel(Rel)->getType();
|
type = getRel(Rel)->getType();
|
||||||
symbol_index = getRel(Rel)->getSymbol();
|
symbol_index = getRel(Rel)->getSymbol();
|
||||||
// TODO: Read implicit addend from section data.
|
// TODO: Read implicit addend from section data.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ELF::SHT_RELA : {
|
case ELF::SHT_RELA: {
|
||||||
type = getRela(Rel)->getType();
|
type = getRela(Rel)->getType();
|
||||||
symbol_index = getRela(Rel)->getSymbol();
|
symbol_index = getRela(Rel)->getSymbol();
|
||||||
addend = getRela(Rel)->r_addend;
|
addend = getRela(Rel)->r_addend;
|
||||||
@ -1733,9 +1733,8 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
switch (Header->e_machine) {
|
switch (Header->e_machine) {
|
||||||
case ELF::EM_X86_64:
|
case ELF::EM_X86_64:
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ELF::R_X86_64_32S:
|
case ELF::R_X86_64_PC8:
|
||||||
res = symname;
|
case ELF::R_X86_64_PC16:
|
||||||
break;
|
|
||||||
case ELF::R_X86_64_PC32: {
|
case ELF::R_X86_64_PC32: {
|
||||||
std::string fmtbuf;
|
std::string fmtbuf;
|
||||||
raw_string_ostream fmt(fmtbuf);
|
raw_string_ostream fmt(fmtbuf);
|
||||||
@ -1744,6 +1743,18 @@ error_code ELFObjectFile<target_endianness, is64Bits>
|
|||||||
Result.append(fmtbuf.begin(), fmtbuf.end());
|
Result.append(fmtbuf.begin(), fmtbuf.end());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ELF::R_X86_64_8:
|
||||||
|
case ELF::R_X86_64_16:
|
||||||
|
case ELF::R_X86_64_32:
|
||||||
|
case ELF::R_X86_64_32S:
|
||||||
|
case ELF::R_X86_64_64: {
|
||||||
|
std::string fmtbuf;
|
||||||
|
raw_string_ostream fmt(fmtbuf);
|
||||||
|
fmt << symname << (addend < 0 ? "" : "+") << addend;
|
||||||
|
fmt.flush();
|
||||||
|
Result.append(fmtbuf.begin(), fmtbuf.end());
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
res = "Unknown";
|
res = "Unknown";
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ RUN: | FileCheck %s -check-prefix ELF-x86-64
|
|||||||
RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-hexagon \
|
RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-hexagon \
|
||||||
RUN: | FileCheck %s -check-prefix ELF-hexagon
|
RUN: | FileCheck %s -check-prefix ELF-hexagon
|
||||||
|
|
||||||
|
RUN: llvm-objdump -r %p/Inputs/relocations.elf-x86-64 \
|
||||||
|
RUN: | FileCheck %s -check-prefix ELF-complex-x86-64
|
||||||
|
|
||||||
COFF-i386: .text
|
COFF-i386: .text
|
||||||
COFF-i386: IMAGE_REL_I386_DIR32 L_.str
|
COFF-i386: IMAGE_REL_I386_DIR32 L_.str
|
||||||
COFF-i386: IMAGE_REL_I386_REL32 _puts
|
COFF-i386: IMAGE_REL_I386_REL32 _puts
|
||||||
@ -36,3 +39,13 @@ ELF-hexagon: R_HEX_HI16 puts
|
|||||||
ELF-hexagon: R_HEX_LO16 puts
|
ELF-hexagon: R_HEX_LO16 puts
|
||||||
ELF-hexagon: R_HEX_B15_PCREL testf
|
ELF-hexagon: R_HEX_B15_PCREL testf
|
||||||
ELF-hexagon: R_HEX_B22_PCREL puts
|
ELF-hexagon: R_HEX_B22_PCREL puts
|
||||||
|
|
||||||
|
ELF-complex-x86-64: .text
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_8 .data-4
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_16 .data-4
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_32 .data-4
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_32S .data-4
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_64 .data-4
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_PC32 .data-4-P
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_32 .data+0
|
||||||
|
ELF-complex-x86-64-NEXT: R_X86_64_32 .data+4
|
||||||
|
Loading…
Reference in New Issue
Block a user