Skip to content

Commit

Permalink
Fix for big-endian hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 17, 2023
1 parent 23576b6 commit fe7c8c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions elf/arch-riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {

auto get_rd = [&](i64 offset) {
// Returns the rd register of an R/I/U/J-type instruction.
return bits(*(u32 *)(contents.data() + offset), 11, 7);
return bits(*(ul32 *)(contents.data() + offset), 11, 7);
};

u64 S = sym.get_addr(ctx);
Expand Down Expand Up @@ -854,7 +854,7 @@ static void shrink_section(Context<E> &ctx, InputSection<E> &isec, bool use_rvc)
isec.extra.r_deltas.resize(rels.size() + 1);

auto get_rd = [&](i64 offset) {
return bits(*(u32 *)(isec.contents.data() + offset), 11, 7);
return bits(*(ul32 *)(isec.contents.data() + offset), 11, 7);
};

i64 delta = 0;
Expand Down

0 comments on commit fe7c8c2

Please sign in to comment.