mirror of
https://github.com/rui314/mold.git
synced 2024-09-11 21:17:28 +03:00
Refactor
This commit is contained in:
parent
fb3c6029d0
commit
852be4a465
@ -768,7 +768,7 @@ template <>
|
||||
void InputSection<E>::copy_contents_riscv(Context<E> &ctx, u8 *buf) {
|
||||
// If a section is not relaxed, we can copy it as a one big chunk.
|
||||
if (extra.r_deltas.empty()) {
|
||||
uncompress_to(ctx, buf);
|
||||
copy_contents(ctx, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,14 +69,14 @@ void InputSection<E>::uncompress(Context<E> &ctx) {
|
||||
return;
|
||||
|
||||
u8 *buf = new u8[sh_size];
|
||||
uncompress_to(ctx, buf);
|
||||
copy_contents(ctx, buf);
|
||||
contents = std::string_view((char *)buf, sh_size);
|
||||
ctx.string_pool.emplace_back(buf);
|
||||
uncompressed = true;
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
void InputSection<E>::uncompress_to(Context<E> &ctx, u8 *buf) {
|
||||
void InputSection<E>::copy_contents(Context<E> &ctx, u8 *buf) {
|
||||
if (!(shdr().sh_flags & SHF_COMPRESSED) || uncompressed) {
|
||||
memcpy(buf, contents.data(), contents.size());
|
||||
return;
|
||||
@ -448,7 +448,7 @@ void InputSection<E>::write_to(Context<E> &ctx, u8 *buf) {
|
||||
if constexpr (is_riscv<E>)
|
||||
copy_contents_riscv(ctx, buf);
|
||||
else
|
||||
uncompress_to(ctx, buf);
|
||||
copy_contents(ctx, buf);
|
||||
|
||||
// Apply relocations
|
||||
if (!ctx.arg.relocatable) {
|
||||
|
@ -244,7 +244,7 @@ public:
|
||||
InputSection(Context<E> &ctx, ObjectFile<E> &file, i64 shndx);
|
||||
|
||||
void uncompress(Context<E> &ctx);
|
||||
void uncompress_to(Context<E> &ctx, u8 *buf);
|
||||
void copy_contents(Context<E> &ctx, u8 *buf);
|
||||
void scan_relocations(Context<E> &ctx);
|
||||
void write_to(Context<E> &ctx, u8 *buf);
|
||||
void apply_reloc_alloc(Context<E> &ctx, u8 *base);
|
||||
|
Loading…
Reference in New Issue
Block a user