diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index dcba56aac1b718b0d0a4bc945d18e62851da9e96..eefb052190f36acf1da3d239fb9df0c30435567a 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2225,7 +2225,7 @@ static int perf_header__adds_write(struct perf_header *header, sec_size = sizeof(*feat_sec) * nr_sections; - sec_start = header->data_offset + header->data_size; + sec_start = header->feat_offset; lseek(fd, sec_start + sec_size, SEEK_SET); for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) { @@ -2304,6 +2304,7 @@ int perf_session__write_header(struct perf_session *session, } header->data_offset = lseek(fd, 0, SEEK_CUR); + header->feat_offset = header->data_offset + header->data_size; if (at_exit) { err = perf_header__adds_write(header, evlist, fd); @@ -2373,7 +2374,7 @@ int perf_header__process_sections(struct perf_header *header, int fd, sec_size = sizeof(*feat_sec) * nr_sections; - lseek(fd, header->data_offset + header->data_size, SEEK_SET); + lseek(fd, header->feat_offset, SEEK_SET); err = perf_header__getbuffer64(header, fd, feat_sec, sec_size); if (err < 0) @@ -2572,6 +2573,7 @@ int perf_file_header__read(struct perf_file_header *header, ph->data_offset = header->data.offset; ph->data_size = header->data.size; + ph->feat_offset = header->data.offset + header->data.size; return 0; } diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 6fa80f947f71beaf54cf666c4060464965b12e30..e6387dcb95c0945826ddc0dc54000f66e1bac7b6 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h @@ -88,6 +88,7 @@ struct perf_header { bool needs_swap; u64 data_offset; u64 data_size; + u64 feat_offset; DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); struct perf_session_env env; };