1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-10 19:26:38 +03:00

Allow R_NONE in .rel.eh_frame

This commit is contained in:
Rui Ueyama 2021-06-08 19:39:22 +09:00
parent c53a71ada3
commit bb050128b3
4 changed files with 8 additions and 15 deletions

View File

@ -99,6 +99,8 @@ void EhFrameSection<I386>::apply_reloc(Context<I386> &ctx,
u8 *base = ctx.buf + this->shdr.sh_offset; u8 *base = ctx.buf + this->shdr.sh_offset;
switch (rel.r_type) { switch (rel.r_type) {
case R_386_NONE:
return;
case R_386_32: case R_386_32:
*(u32 *)(base + loc) = val; *(u32 *)(base + loc) = val;
return; return;

View File

@ -73,6 +73,8 @@ void EhFrameSection<X86_64>::apply_reloc(Context<X86_64> &ctx,
u8 *base = ctx.buf + this->shdr.sh_offset; u8 *base = ctx.buf + this->shdr.sh_offset;
switch (rel.r_type) { switch (rel.r_type) {
case R_X86_64_NONE:
return;
case R_X86_64_32: case R_X86_64_32:
*(u32 *)(base + loc) = val; *(u32 *)(base + loc) = val;
return; return;

2
elf.h
View File

@ -609,6 +609,7 @@ template <typename E> struct ElfNhdr;
struct X86_64 { struct X86_64 {
typedef u64 WordTy; typedef u64 WordTy;
static constexpr u32 R_NONE = R_X86_64_NONE;
static constexpr u32 R_COPY = R_X86_64_COPY; static constexpr u32 R_COPY = R_X86_64_COPY;
static constexpr u32 R_GLOB_DAT = R_X86_64_GLOB_DAT; static constexpr u32 R_GLOB_DAT = R_X86_64_GLOB_DAT;
static constexpr u32 R_JUMP_SLOT = R_X86_64_JUMP_SLOT; static constexpr u32 R_JUMP_SLOT = R_X86_64_JUMP_SLOT;
@ -643,6 +644,7 @@ template <> struct ElfNhdr<X86_64> : public Elf64Nhdr {};
struct I386 { struct I386 {
typedef u32 WordTy; typedef u32 WordTy;
static constexpr u32 R_NONE = R_386_NONE;
static constexpr u32 R_COPY = R_386_COPY; static constexpr u32 R_COPY = R_386_COPY;
static constexpr u32 R_GLOB_DAT = R_386_GLOB_DAT; static constexpr u32 R_GLOB_DAT = R_386_GLOB_DAT;
static constexpr u32 R_JUMP_SLOT = R_386_JUMP_SLOT; static constexpr u32 R_JUMP_SLOT = R_386_JUMP_SLOT;

View File

@ -330,20 +330,6 @@ void ObjectFile<E>::initialize_ehframe_sections(Context<E> &ctx) {
} }
} }
template <typename E>
static bool is_valid_ehframe_reloc(u32 type);
template <>
bool is_valid_ehframe_reloc<X86_64>(u32 type) {
return type == R_X86_64_32 || type == R_X86_64_64 ||
type == R_X86_64_PC32 || type == R_X86_64_PC64;
}
template <>
bool is_valid_ehframe_reloc<I386>(u32 type) {
return type == R_386_32 || type == R_386_PC32;
}
// .eh_frame contains data records explaining how to handle exceptions. // .eh_frame contains data records explaining how to handle exceptions.
// When an exception is thrown, the runtime searches a record from // When an exception is thrown, the runtime searches a record from
// .eh_frame with the current program counter as a key. A record that // .eh_frame with the current program counter as a key. A record that
@ -379,7 +365,8 @@ void ObjectFile<E>::read_ehframe(Context<E> &ctx, InputSection<E> &isec) {
// Verify relocations. // Verify relocations.
for (i64 i = 1; i < rels.size(); i++) for (i64 i = 1; i < rels.size(); i++)
if (rels[i].r_offset <= rels[i - 1].r_offset) if (rels[i].r_type != E::R_NONE &&
rels[i].r_offset <= rels[i - 1].r_offset)
Fatal(ctx) << isec << ": relocation offsets must increase monotonically"; Fatal(ctx) << isec << ": relocation offsets must increase monotonically";
// Read CIEs and FDEs until empty. // Read CIEs and FDEs until empty.