mold/0003-ELF-i386-Fix-assertion...

41 lines
1.5 KiB
Diff

From b6d3255e1a498d5a966bd303eb09390aa24ef596 Mon Sep 17 00:00:00 2001
Message-Id: <b6d3255e1a498d5a966bd303eb09390aa24ef596.1666197268.git.github@sicherha.de>
In-Reply-To: <6c0c571d629d924e3f59d8710de6589848204e17.1666197268.git.github@sicherha.de>
References: <6c0c571d629d924e3f59d8710de6589848204e17.1666197268.git.github@sicherha.de>
From: Rui Ueyama <ruiu@bluewhale.systems>
Date: Wed, 19 Oct 2022 20:14:53 +0800
Subject: [PATCH 3/3] [ELF][i386] Fix assertion failure
https://github.com/rui314/mold/issues/794
---
elf/arch-i386.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/elf/arch-i386.cc b/elf/arch-i386.cc
index 20563faa..87524fd1 100644
--- a/elf/arch-i386.cc
+++ b/elf/arch-i386.cc
@@ -234,7 +234,8 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
} else {
// Relax GD to LE
switch (rels[i + 1].r_type) {
- case R_386_PLT32: {
+ case R_386_PLT32:
+ case R_386_PC32: {
static const u8 insn[] = {
0x65, 0xa1, 0, 0, 0, 0, // mov %gs:0, %eax
0x81, 0xe8, 0, 0, 0, 0, // add $val, %eax
@@ -266,7 +267,8 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
} else {
// Relax LD to LE
switch (rels[i + 1].r_type) {
- case R_386_PLT32: {
+ case R_386_PLT32:
+ case R_386_PC32: {
static const u8 insn[] = {
0x31, 0xc0, // xor %eax, %eax
0x65, 0x8b, 0x00, // mov %gs:(%eax), %eax
--
2.37.3