@@ -1386,6 +1386,7 @@ static off_t kcore__write(struct kcore *kcore)
1386
1386
1387
1387
struct phdr_data {
1388
1388
off_t offset ;
1389
+ off_t rel ;
1389
1390
u64 addr ;
1390
1391
u64 len ;
1391
1392
struct list_head node ;
@@ -1404,6 +1405,9 @@ struct kcore_copy_info {
1404
1405
struct list_head phdrs ;
1405
1406
};
1406
1407
1408
+ #define kcore_copy__for_each_phdr (k , p ) \
1409
+ list_for_each_entry((p), &(k)->phdrs, node)
1410
+
1407
1411
static int kcore_copy__process_kallsyms (void * arg , const char * name , char type ,
1408
1412
u64 start )
1409
1413
{
@@ -1518,11 +1522,21 @@ static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
1518
1522
if (kci -> modules_map .len )
1519
1523
list_add_tail (& kci -> modules_map .node , & kci -> phdrs );
1520
1524
1521
- kci -> phnum = !!kci -> kernel_map .len + !!kci -> modules_map .len ;
1522
-
1523
1525
return 0 ;
1524
1526
}
1525
1527
1528
+ static void kcore_copy__layout (struct kcore_copy_info * kci )
1529
+ {
1530
+ struct phdr_data * p ;
1531
+ off_t rel = 0 ;
1532
+
1533
+ kcore_copy__for_each_phdr (kci , p ) {
1534
+ p -> rel = rel ;
1535
+ rel += p -> len ;
1536
+ kci -> phnum += 1 ;
1537
+ }
1538
+ }
1539
+
1526
1540
static int kcore_copy__calc_maps (struct kcore_copy_info * kci , const char * dir ,
1527
1541
Elf * elf )
1528
1542
{
@@ -1558,7 +1572,12 @@ static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir,
1558
1572
if (kci -> first_module && !kci -> last_module_symbol )
1559
1573
return -1 ;
1560
1574
1561
- return kcore_copy__read_maps (kci , elf );
1575
+ if (kcore_copy__read_maps (kci , elf ))
1576
+ return -1 ;
1577
+
1578
+ kcore_copy__layout (kci );
1579
+
1580
+ return 0 ;
1562
1581
}
1563
1582
1564
1583
static int kcore_copy__copy_file (const char * from_dir , const char * to_dir ,
0 commit comments