@@ -361,6 +361,7 @@ static const char* sw_event_names[PERF_COUNT_SW_MAX] = {
361
361
362
362
struct Map {
363
363
uint64_t Start, End, Adjust;
364
+ bool isSO;
364
365
const char *Filename;
365
366
};
366
367
@@ -528,10 +529,14 @@ class SymTabOutput : public std::vector<Symbol> {
528
529
void reset (Map *M) {
529
530
clear ();
530
531
// Fetch both dynamic and static symbols, sort and unique them.
531
- uint64_t segmentStart = fetchExecSegment (M);
532
- /* Adjust the symbol to a value relative to the start of the load address
533
- to match up with registerNewMapping. */
534
- M->Adjust -= segmentStart;
532
+ /* If we're a relocatable object then take the actual start of the text
533
+ segment into account. */
534
+ if (M->isSO ) {
535
+ uint64_t segmentStart = fetchExecSegment (M);
536
+ /* Adjust the symbol to a value relative to the start of the load address
537
+ to match up with registerNewMapping. */
538
+ M->Adjust -= segmentStart;
539
+ }
535
540
fetchSymbols (M);
536
541
537
542
std::sort (begin (), end ());
@@ -852,7 +857,7 @@ void PerfReader::registerNewMapping(unsigned char *Buf, const char *Filename) {
852
857
bool IsSO = IsSharedObject (BinaryCacheRoot + std::string (Filename));
853
858
uint64_t End = E->start + E->extent ;
854
859
uint64_t Adjust = IsSO ? E->start - E->pgoff : 0 ;
855
- Maps.push_back ({E->start , End, Adjust, Filename});
860
+ Maps.push_back ({E->start , End, Adjust, IsSO, Filename});
856
861
857
862
unsigned char *EndOfEvent = Buf + E->header .size ;
858
863
// FIXME: The first EventID is used for every event.
0 commit comments