@@ -336,40 +336,26 @@ ELFFile<ELFT>::decode_relrs(Elf_Relr_Range relrs) const {
336
336
std::vector<Elf_Rel> Relocs;
337
337
338
338
// Word type: uint32_t for Elf32, and uint64_t for Elf64.
339
- typedef typename ELFT::uint Word ;
339
+ using Addr = typename ELFT::uint;
340
340
341
- // Word size in number of bytes.
342
- const size_t WordSize = sizeof (Word);
343
-
344
- // Number of bits used for the relocation offsets bitmap.
345
- // These many relative relocations can be encoded in a single entry.
346
- const size_t NBits = 8 *WordSize - 1 ;
347
-
348
- Word Base = 0 ;
349
- for (const Elf_Relr &R : relrs) {
350
- Word Entry = R;
351
- if ((Entry&1 ) == 0 ) {
341
+ Addr Base = 0 ;
342
+ for (Elf_Relr R : relrs) {
343
+ typename ELFT::uint Entry = R;
344
+ if ((Entry & 1 ) == 0 ) {
352
345
// Even entry: encodes the offset for next relocation.
353
346
Rel.r_offset = Entry;
354
347
Relocs.push_back (Rel);
355
348
// Set base offset for subsequent bitmap entries.
356
- Base = Entry + WordSize;
357
- continue ;
358
- }
359
-
360
- // Odd entry: encodes bitmap for relocations starting at base.
361
- Word Offset = Base;
362
- while (Entry != 0 ) {
363
- Entry >>= 1 ;
364
- if ((Entry&1 ) != 0 ) {
365
- Rel.r_offset = Offset;
366
- Relocs.push_back (Rel);
367
- }
368
- Offset += WordSize;
349
+ Base = Entry + sizeof (Addr);
350
+ } else {
351
+ // Odd entry: encodes bitmap for relocations starting at base.
352
+ for (Addr Offset = Base; (Entry >>= 1 ) != 0 ; Offset += sizeof (Addr))
353
+ if ((Entry & 1 ) != 0 ) {
354
+ Rel.r_offset = Offset;
355
+ Relocs.push_back (Rel);
356
+ }
357
+ Base += (CHAR_BIT * sizeof (Entry) - 1 ) * sizeof (Addr);
369
358
}
370
-
371
- // Advance base offset by NBits words.
372
- Base += NBits * WordSize;
373
359
}
374
360
375
361
return Relocs;
0 commit comments