@@ -34,6 +34,8 @@ const EF_MIPS_MACH: u32 = 0x00FF0000;
34
34
const EF_MIPS_MACH_ALLEGREX : u32 = 0x00840000 ;
35
35
const EF_MIPS_MACH_5900 : u32 = 0x00920000 ;
36
36
37
+ const R_MIPS15_S3 : u32 = 119 ;
38
+
37
39
impl ObjArchMips {
38
40
pub fn new ( object : & File ) -> Result < Self > {
39
41
let mut abi = Abi :: NUMERIC ;
@@ -169,6 +171,18 @@ impl ObjArch for ObjArchMips {
169
171
) ) ) ;
170
172
args. push ( ObjInsArg :: PlainText ( ")" . into ( ) ) ) ;
171
173
}
174
+ // OperandType::r5900_immediate15 => match reloc {
175
+ // Some(reloc)
176
+ // if reloc.flags == RelocationFlags::Elf { r_type: R_MIPS15_S3 } =>
177
+ // {
178
+ // push_reloc(&mut args, reloc)?;
179
+ // }
180
+ // _ => {
181
+ // args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
182
+ // op.disassemble(&instruction, None).into(),
183
+ // )));
184
+ // }
185
+ // },
172
186
_ => {
173
187
args. push ( ObjInsArg :: Arg ( ObjInsArgValue :: Opaque (
174
188
op. disassemble ( & instruction, None ) . into ( ) ,
@@ -205,13 +219,14 @@ impl ObjArch for ObjArchMips {
205
219
let addend = self . endianness . read_u32_bytes ( data) ;
206
220
Ok ( match reloc. flags ( ) {
207
221
RelocationFlags :: Elf { r_type : elf:: R_MIPS_32 } => addend as i64 ,
222
+ RelocationFlags :: Elf { r_type : elf:: R_MIPS_26 } => ( ( addend & 0x03FFFFFF ) << 2 ) as i64 ,
208
223
RelocationFlags :: Elf { r_type : elf:: R_MIPS_HI16 } => {
209
224
( ( addend & 0x0000FFFF ) << 16 ) as i32 as i64
210
225
}
211
226
RelocationFlags :: Elf {
212
227
r_type : elf:: R_MIPS_LO16 | elf:: R_MIPS_GOT16 | elf:: R_MIPS_CALL16 ,
213
228
} => ( addend & 0x0000FFFF ) as i16 as i64 ,
214
- RelocationFlags :: Elf { r_type : elf:: R_MIPS_GPREL16 } => {
229
+ RelocationFlags :: Elf { r_type : elf:: R_MIPS_GPREL16 | elf :: R_MIPS_LITERAL } => {
215
230
let RelocationTarget :: Symbol ( idx) = reloc. target ( ) else {
216
231
bail ! ( "Unsupported R_MIPS_GPREL16 relocation against a non-symbol" ) ;
217
232
} ;
@@ -225,23 +240,25 @@ impl ObjArch for ObjArchMips {
225
240
( addend & 0x0000FFFF ) as i16 as i64
226
241
}
227
242
}
228
- RelocationFlags :: Elf { r_type : elf:: R_MIPS_26 } => ( ( addend & 0x03FFFFFF ) << 2 ) as i64 ,
229
243
RelocationFlags :: Elf { r_type : elf:: R_MIPS_PC16 } => 0 , // PC-relative relocation
244
+ RelocationFlags :: Elf { r_type : R_MIPS15_S3 } => ( ( addend & 0x001FFFC0 ) >> 3 ) as i64 ,
230
245
flags => bail ! ( "Unsupported MIPS implicit relocation {flags:?}" ) ,
231
246
} )
232
247
}
233
248
234
249
fn display_reloc ( & self , flags : RelocationFlags ) -> Cow < ' static , str > {
235
250
match flags {
236
251
RelocationFlags :: Elf { r_type } => match r_type {
252
+ elf:: R_MIPS_32 => Cow :: Borrowed ( "R_MIPS_32" ) ,
253
+ elf:: R_MIPS_26 => Cow :: Borrowed ( "R_MIPS_26" ) ,
237
254
elf:: R_MIPS_HI16 => Cow :: Borrowed ( "R_MIPS_HI16" ) ,
238
255
elf:: R_MIPS_LO16 => Cow :: Borrowed ( "R_MIPS_LO16" ) ,
256
+ elf:: R_MIPS_GPREL16 => Cow :: Borrowed ( "R_MIPS_GPREL16" ) ,
257
+ elf:: R_MIPS_LITERAL => Cow :: Borrowed ( "R_MIPS_LITERAL" ) ,
239
258
elf:: R_MIPS_GOT16 => Cow :: Borrowed ( "R_MIPS_GOT16" ) ,
240
259
elf:: R_MIPS_PC16 => Cow :: Borrowed ( "R_MIPS_PC16" ) ,
241
260
elf:: R_MIPS_CALL16 => Cow :: Borrowed ( "R_MIPS_CALL16" ) ,
242
- elf:: R_MIPS_GPREL16 => Cow :: Borrowed ( "R_MIPS_GPREL16" ) ,
243
- elf:: R_MIPS_32 => Cow :: Borrowed ( "R_MIPS_32" ) ,
244
- elf:: R_MIPS_26 => Cow :: Borrowed ( "R_MIPS_26" ) ,
261
+ R_MIPS15_S3 => Cow :: Borrowed ( "R_MIPS15_S3" ) ,
245
262
_ => Cow :: Owned ( format ! ( "<{flags:?}>" ) ) ,
246
263
} ,
247
264
_ => Cow :: Owned ( format ! ( "<{flags:?}>" ) ) ,
@@ -277,7 +294,11 @@ fn push_reloc(args: &mut Vec<ObjInsArg>, reloc: &ObjReloc) -> Result<()> {
277
294
args. push ( ObjInsArg :: Reloc ) ;
278
295
args. push ( ObjInsArg :: PlainText ( ")" . into ( ) ) ) ;
279
296
}
280
- elf:: R_MIPS_32 | elf:: R_MIPS_26 | elf:: R_MIPS_PC16 => {
297
+ elf:: R_MIPS_32
298
+ | elf:: R_MIPS_26
299
+ | elf:: R_MIPS_LITERAL
300
+ | elf:: R_MIPS_PC16
301
+ | R_MIPS15_S3 => {
281
302
args. push ( ObjInsArg :: Reloc ) ;
282
303
}
283
304
_ => bail ! ( "Unsupported ELF MIPS relocation type {r_type}" ) ,
0 commit comments