aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/header.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 709e3252f049..942f7da8bf84 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -173,6 +173,20 @@ static int do_write(int fd, const void *buf, size_t size)
173 return 0; 173 return 0;
174} 174}
175 175
176#define NAME_ALIGN 64
177
178static int write_padded(int fd, const void *bf, size_t count,
179 size_t count_aligned)
180{
181 static const char zero_buf[NAME_ALIGN];
182 int err = do_write(fd, bf, count);
183
184 if (!err)
185 err = do_write(fd, zero_buf, count_aligned - count);
186
187 return err;
188}
189
176#define dsos__for_each_with_build_id(pos, head) \ 190#define dsos__for_each_with_build_id(pos, head) \
177 list_for_each_entry(pos, head, node) \ 191 list_for_each_entry(pos, head, node) \
178 if (!pos->has_build_id) \ 192 if (!pos->has_build_id) \
@@ -181,9 +195,7 @@ static int do_write(int fd, const void *buf, size_t size)
181 195
182static int __dsos__write_buildid_table(struct list_head *head, int fd) 196static int __dsos__write_buildid_table(struct list_head *head, int fd)
183{ 197{
184#define NAME_ALIGN 64
185 struct dso *pos; 198 struct dso *pos;
186 static const char zero_buf[NAME_ALIGN];
187 199
188 dsos__for_each_with_build_id(pos, head) { 200 dsos__for_each_with_build_id(pos, head) {
189 int err; 201 int err;
@@ -197,10 +209,8 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)
197 err = do_write(fd, &b, sizeof(b)); 209 err = do_write(fd, &b, sizeof(b));
198 if (err < 0) 210 if (err < 0)
199 return err; 211 return err;
200 err = do_write(fd, pos->long_name, pos->long_name_len + 1); 212 err = write_padded(fd, pos->long_name,
201 if (err < 0) 213 pos->long_name_len + 1, len);
202 return err;
203 err = do_write(fd, zero_buf, len - pos->long_name_len - 1);
204 if (err < 0) 214 if (err < 0)
205 return err; 215 return err;
206 } 216 }