From b721514f9809f219daa233e522a8f52d73bdeeb9 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sun, 4 Jul 2021 21:44:43 +0900 Subject: [PATCH] Rename a variable --- arch_i386.cc | 36 +++++++++++++++++----------------- arch_x86_64.cc | 50 +++++++++++++++++++++++------------------------ input_sections.cc | 10 +++++----- mold.h | 2 +- object_file.cc | 2 +- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/arch_i386.cc b/arch_i386.cc index 4f63ad38..2b5f6a73 100644 --- a/arch_i386.cc +++ b/arch_i386.cc @@ -156,7 +156,7 @@ void InputSection::apply_reloc_alloc(Context &ctx, u8 *base) { file.reldyn_offset + this->reldyn_offset); for (i64 i = 0; i < rels.size(); i++) { - if (rel_types[i] == R_NONE) + if (rel_exprs[i] == R_NONE) continue; const ElfRel &rel = rels[i]; @@ -177,7 +177,7 @@ void InputSection::apply_reloc_alloc(Context &ctx, u8 *base) { #define G (sym.get_got_addr(ctx) - ctx.got->shdr.sh_addr) #define GOTPLT ctx.gotplt->shdr.sh_addr - switch (rel_types[i]) { + switch (rel_exprs[i]) { case R_ABS: write(S + A); break; @@ -322,7 +322,7 @@ void InputSection::scan_relocations(Context &ctx) { const ElfRel &rel = rels[i]; if (rel.r_type == R_386_NONE) { - rel_types[i] = R_NONE; + rel_exprs[i] = R_NONE; break; } @@ -389,59 +389,59 @@ void InputSection::scan_relocations(Context &ctx) { case R_386_GOT32: case R_386_GOT32X: sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOT; + rel_exprs[i] = R_GOT; break; case R_386_PLT32: if (sym.is_imported) sym.flags |= NEEDS_PLT; - rel_types[i] = R_PC; + rel_exprs[i] = R_PC; break; case R_386_GOTOFF: - rel_types[i] = R_GOTOFF; + rel_exprs[i] = R_GOTOFF; break; case R_386_GOTPC: sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOTPC; + rel_exprs[i] = R_GOTPC; break; case R_386_TLS_GOTIE: sym.flags |= NEEDS_GOTTP; - rel_types[i] = R_TLS_GOTIE; + rel_exprs[i] = R_TLS_GOTIE; break; case R_386_TLS_LE: sym.flags |= NEEDS_GOTTP; - rel_types[i] = R_TLS_LE; + rel_exprs[i] = R_TLS_LE; break; case R_386_TLS_IE: sym.flags |= NEEDS_GOTTP; - rel_types[i] = R_TLS_IE; + rel_exprs[i] = R_TLS_IE; break; case R_386_TLS_GD: sym.flags |= NEEDS_TLSGD; - rel_types[i] = R_TLS_GD; + rel_exprs[i] = R_TLS_GD; break; case R_386_TLS_LDM: sym.flags |= NEEDS_TLSLD; - rel_types[i] = R_TLS_LD; + rel_exprs[i] = R_TLS_LD; break; case R_386_TLS_LDO_32: - rel_types[i] = R_TPOFF; + rel_exprs[i] = R_TPOFF; break; case R_386_SIZE32: - rel_types[i] = R_SIZE; + rel_exprs[i] = R_SIZE; break; case R_386_TLS_GOTDESC: if (ctx.arg.relax && !ctx.arg.shared) { - rel_types[i] = R_TLS_GOTDESC_RELAX; + rel_exprs[i] = R_TLS_GOTDESC_RELAX; } else { sym.flags |= NEEDS_TLSDESC; - rel_types[i] = R_TLS_GOTDESC; + rel_exprs[i] = R_TLS_GOTDESC; } break; case R_386_TLS_DESC_CALL: if (ctx.arg.relax && !ctx.arg.shared) - rel_types[i] = R_TLS_DESC_CALL_RELAX; + rel_exprs[i] = R_TLS_DESC_CALL_RELAX; else - rel_types[i] = R_NONE; + rel_exprs[i] = R_NONE; break; default: Error(ctx) << *this << ": unknown relocation: " diff --git a/arch_x86_64.cc b/arch_x86_64.cc index e57d5bbe..1d52050f 100644 --- a/arch_x86_64.cc +++ b/arch_x86_64.cc @@ -266,7 +266,7 @@ void InputSection::apply_reloc_alloc(Context &ctx, u8 *base) { file.reldyn_offset + this->reldyn_offset); for (i64 i = 0; i < rels.size(); i++) { - if (rel_types[i] == R_NONE) + if (rel_exprs[i] == R_NONE) continue; const ElfRel &rel = rels[i]; @@ -288,7 +288,7 @@ void InputSection::apply_reloc_alloc(Context &ctx, u8 *base) { #define G (sym.get_got_addr(ctx) - ctx.got->shdr.sh_addr) #define GOT ctx.got->shdr.sh_addr - switch (rel_types[i]) { + switch (rel_exprs[i]) { case R_ABS: write(S + A); break; @@ -489,7 +489,7 @@ void InputSection::scan_relocations(Context &ctx) { const ElfRel &rel = rels[i]; if (rel.r_type == R_X86_64_NONE) { - rel_types[i] = R_NONE; + rel_exprs[i] = R_NONE; continue; } @@ -564,17 +564,17 @@ void InputSection::scan_relocations(Context &ctx) { case R_X86_64_GOT32: case R_X86_64_GOT64: sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOT; + rel_exprs[i] = R_GOT; break; case R_X86_64_GOTPC32: case R_X86_64_GOTPC64: sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOTPC; + rel_exprs[i] = R_GOTPC; break; case R_X86_64_GOTPCREL: case R_X86_64_GOTPCREL64: sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOTPCREL; + rel_exprs[i] = R_GOTPCREL; break; case R_X86_64_GOTPCRELX: { if (rel.r_addend != -4) @@ -582,10 +582,10 @@ void InputSection::scan_relocations(Context &ctx) { if (ctx.arg.relax && !sym.is_imported && sym.is_relative(ctx) && relax_gotpcrelx(loc - 2)) { - rel_types[i] = R_GOTPCRELX_RELAX; + rel_exprs[i] = R_GOTPCRELX_RELAX; } else { sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOTPCREL; + rel_exprs[i] = R_GOTPCREL; } break; } @@ -595,16 +595,16 @@ void InputSection::scan_relocations(Context &ctx) { if (ctx.arg.relax && !sym.is_imported && sym.is_relative(ctx) && relax_rex_gotpcrelx(loc - 3)) { - rel_types[i] = R_REX_GOTPCRELX_RELAX; + rel_exprs[i] = R_REX_GOTPCRELX_RELAX; } else { sym.flags |= NEEDS_GOT; - rel_types[i] = R_GOTPCREL; + rel_exprs[i] = R_GOTPCREL; } break; case R_X86_64_PLT32: if (sym.is_imported) sym.flags |= NEEDS_PLT; - rel_types[i] = R_PC; + rel_exprs[i] = R_PC; break; case R_X86_64_TLSGD: { if (i + 1 == rels.size()) @@ -612,10 +612,10 @@ void InputSection::scan_relocations(Context &ctx) { << ": TLSGD reloc must be followed by PLT32 or GOTPCREL"; if (ctx.arg.relax && !ctx.arg.shared && !sym.is_imported) { - rel_types[i++] = R_TLSGD_RELAX_LE; + rel_exprs[i++] = R_TLSGD_RELAX_LE; } else { sym.flags |= NEEDS_TLSGD; - rel_types[i] = R_TLSGD; + rel_exprs[i] = R_TLSGD; } break; } @@ -627,10 +627,10 @@ void InputSection::scan_relocations(Context &ctx) { Fatal(ctx) << *this << ": TLSLD reloc refers external symbol " << sym; if (ctx.arg.relax && !ctx.arg.shared) { - rel_types[i++] = R_TLSLD_RELAX_LE; + rel_exprs[i++] = R_TLSLD_RELAX_LE; } else { sym.flags |= NEEDS_TLSLD; - rel_types[i] = R_TLSLD; + rel_exprs[i] = R_TLSLD; } break; case R_X86_64_DTPOFF32: @@ -639,23 +639,23 @@ void InputSection::scan_relocations(Context &ctx) { Fatal(ctx) << *this << ": DTPOFF reloc refers external symbol " << sym; if (ctx.arg.relax && !ctx.arg.shared) - rel_types[i] = R_DTPOFF_RELAX; + rel_exprs[i] = R_DTPOFF_RELAX; else - rel_types[i] = R_DTPOFF; + rel_exprs[i] = R_DTPOFF; break; case R_X86_64_TPOFF32: case R_X86_64_TPOFF64: - rel_types[i] = R_TPOFF; + rel_exprs[i] = R_TPOFF; break; case R_X86_64_GOTTPOFF: ctx.has_gottp_rel = true; if (ctx.arg.relax && !ctx.arg.shared && !sym.is_imported && relax_gottpoff(loc - 3)) { - rel_types[i] = R_GOTTPOFF_RELAX; + rel_exprs[i] = R_GOTTPOFF_RELAX; } else { sym.flags |= NEEDS_GOTTP; - rel_types[i] = R_GOTTPOFF; + rel_exprs[i] = R_GOTTPOFF; } break; case R_X86_64_GOTPC32_TLSDESC: @@ -664,21 +664,21 @@ void InputSection::scan_relocations(Context &ctx) { << " against an invalid code sequence"; if (ctx.arg.relax && !ctx.arg.shared) { - rel_types[i] = R_GOTPC_TLSDESC_RELAX_LE; + rel_exprs[i] = R_GOTPC_TLSDESC_RELAX_LE; } else { sym.flags |= NEEDS_TLSDESC; - rel_types[i] = R_GOTPC_TLSDESC; + rel_exprs[i] = R_GOTPC_TLSDESC; } break; case R_X86_64_SIZE32: case R_X86_64_SIZE64: - rel_types[i] = R_SIZE; + rel_exprs[i] = R_SIZE; break; case R_X86_64_TLSDESC_CALL: if (ctx.arg.relax && !ctx.arg.shared) - rel_types[i] = R_TLSDESC_CALL_RELAX; + rel_exprs[i] = R_TLSDESC_CALL_RELAX; else - rel_types[i] = R_NONE; + rel_exprs[i] = R_NONE; break; default: Error(ctx) << *this << ": unknown relocation: " diff --git a/input_sections.cc b/input_sections.cc index 92b01def..f5f15ee9 100644 --- a/input_sections.cc +++ b/input_sections.cc @@ -90,7 +90,7 @@ void InputSection::dispatch(Context &ctx, Action table[3][4], switch (action) { case NONE: - rel_types[i] = rel_type; + rel_exprs[i] = rel_type; return; case ERROR: break; @@ -102,11 +102,11 @@ void InputSection::dispatch(Context &ctx, Action table[3][4], << " protected symbol '" << sym << "', defined in " << *sym.file; sym.flags |= NEEDS_COPYREL; - rel_types[i] = rel_type; + rel_exprs[i] = rel_type; return; case PLT: sym.flags |= NEEDS_PLT; - rel_types[i] = rel_type; + rel_exprs[i] = rel_type; return; case DYNREL: if (!is_writable) { @@ -115,7 +115,7 @@ void InputSection::dispatch(Context &ctx, Action table[3][4], ctx.has_textrel = true; } sym.flags |= NEEDS_DYNSYM; - rel_types[i] = R_DYN; + rel_exprs[i] = R_DYN; file.num_dynrel++; return; case BASEREL: @@ -124,7 +124,7 @@ void InputSection::dispatch(Context &ctx, Action table[3][4], break; ctx.has_textrel = true; } - rel_types[i] = R_BASEREL; + rel_exprs[i] = R_BASEREL; file.num_dynrel++; return; default: diff --git a/mold.h b/mold.h index 14ae5754..906dfa34 100644 --- a/mold.h +++ b/mold.h @@ -279,7 +279,7 @@ public: std::string_view contents; std::unique_ptr[]> rel_fragments; - std::unique_ptr rel_types; + std::unique_ptr rel_exprs; i32 fde_begin = -1; i32 fde_end = -1; diff --git a/object_file.cc b/object_file.cc index 211d8e2a..0f34c33e 100644 --- a/object_file.cc +++ b/object_file.cc @@ -248,7 +248,7 @@ void ObjectFile::initialize_sections(Context &ctx) { if (target->shdr.sh_flags & SHF_ALLOC) { i64 size = shdr.sh_size / sizeof(ElfRel); - target->rel_types.reset(new u8[size]); + target->rel_exprs.reset(new u8[size]); } } }