Skip to content

Commit

Permalink
ExecutionEngine: support IMAGE_REL_AMD64_SECTION relocations
Browse files Browse the repository at this point in the history
This relocation type is often used for debug information on Windows.  We
would previously abort due to the unreachable for the unhandled
relocation type.  Add support for this to prevent LLDB from aborting if
it encounters this relocation type.
  • Loading branch information
compnerd committed Jul 27, 2023
1 parent a90228b commit d4a5bef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ class RuntimeDyldCOFFX86_64 : public RuntimeDyldCOFF {
break;
}

case COFF::IMAGE_REL_AMD64_SECTION: {
assert(static_cast<int16_t>(RE.SectionID) <= INT16_MAX && "Relocation overflow");
assert(static_cast<int16_t>(RE.SectionID) >= INT16_MIN && "Relocation underflow");
writeBytesUnaligned(RE.SectionID, Target, 2);
break;
}

default:
llvm_unreachable("Relocation type not implemented yet!");
break;
Expand Down
9 changes: 9 additions & 0 deletions llvm/test/ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
# RUN: -dummy-extern external_data=0x2 -verify -check=%s %t/COFF_x86_64.o


.section section,"rx"
section:
.long 0
Lreloc:
.long 0
# rtdyld-check: *{2}Lreloc = 1
.reloc 4, secidx, section+4


.text
.def F;
.scl 2;
Expand Down

0 comments on commit d4a5bef

Please sign in to comment.