@@ -6,7 +6,7 @@ use iced_x86::{
6
6
Decoder , DecoderOptions , DecoratorKind , FormatterOutput , FormatterTextKind , GasFormatter ,
7
7
Instruction , IntelFormatter , MasmFormatter , NasmFormatter , NumberKind , OpKind , Register ,
8
8
} ;
9
- use object:: { Endian as _, Object as _, ObjectSection as _, pe} ;
9
+ use object:: { Endian as _, Object as _, ObjectSection as _, elf , pe} ;
10
10
11
11
use crate :: {
12
12
arch:: Arch ,
@@ -67,15 +67,23 @@ impl ArchX86 {
67
67
pe:: IMAGE_REL_I386_DIR32 | pe:: IMAGE_REL_I386_REL32 => Some ( 4 ) ,
68
68
_ => None ,
69
69
} ,
70
- _ => None ,
70
+ RelocationFlags :: Elf ( typ) => match typ {
71
+ elf:: R_386_32 | elf:: R_386_PC32 => Some ( 4 ) ,
72
+ elf:: R_386_16 => Some ( 2 ) ,
73
+ _ => None ,
74
+ } ,
71
75
} ,
72
76
Architecture :: X86_64 => match flags {
73
77
RelocationFlags :: Coff ( typ) => match typ {
74
78
pe:: IMAGE_REL_AMD64_ADDR32NB | pe:: IMAGE_REL_AMD64_REL32 => Some ( 4 ) ,
75
79
pe:: IMAGE_REL_AMD64_ADDR64 => Some ( 8 ) ,
76
80
_ => None ,
77
81
} ,
78
- _ => None ,
82
+ RelocationFlags :: Elf ( typ) => match typ {
83
+ elf:: R_X86_64_PC32 => Some ( 4 ) ,
84
+ elf:: R_X86_64_64 => Some ( 8 ) ,
85
+ _ => None ,
86
+ } ,
79
87
} ,
80
88
}
81
89
}
@@ -227,20 +235,23 @@ impl Arch for ArchX86 {
227
235
) -> Result < i64 > {
228
236
match self . arch {
229
237
Architecture :: X86 => match flags {
230
- RelocationFlags :: Coff ( pe:: IMAGE_REL_I386_DIR32 | pe:: IMAGE_REL_I386_REL32 ) => {
238
+ RelocationFlags :: Coff ( pe:: IMAGE_REL_I386_DIR32 | pe:: IMAGE_REL_I386_REL32 )
239
+ | RelocationFlags :: Elf ( elf:: R_386_32 | elf:: R_386_PC32 ) => {
231
240
let data =
232
241
section. data ( ) ?[ address as usize ..address as usize + 4 ] . try_into ( ) ?;
233
242
Ok ( self . endianness . read_i32_bytes ( data) as i64 )
234
243
}
235
244
flags => bail ! ( "Unsupported x86 implicit relocation {flags:?}" ) ,
236
245
} ,
237
246
Architecture :: X86_64 => match flags {
238
- RelocationFlags :: Coff ( pe:: IMAGE_REL_AMD64_ADDR32NB | pe:: IMAGE_REL_AMD64_REL32 ) => {
247
+ RelocationFlags :: Coff ( pe:: IMAGE_REL_AMD64_ADDR32NB | pe:: IMAGE_REL_AMD64_REL32 )
248
+ | RelocationFlags :: Elf ( elf:: R_X86_64_32 | elf:: R_X86_64_PC32 ) => {
239
249
let data =
240
250
section. data ( ) ?[ address as usize ..address as usize + 4 ] . try_into ( ) ?;
241
251
Ok ( self . endianness . read_i32_bytes ( data) as i64 )
242
252
}
243
- RelocationFlags :: Coff ( pe:: IMAGE_REL_AMD64_ADDR64 ) => {
253
+ RelocationFlags :: Coff ( pe:: IMAGE_REL_AMD64_ADDR64 )
254
+ | RelocationFlags :: Elf ( elf:: R_X86_64_64 ) => {
244
255
let data =
245
256
section. data ( ) ?[ address as usize ..address as usize + 8 ] . try_into ( ) ?;
246
257
Ok ( self . endianness . read_i64_bytes ( data) )
0 commit comments