Message ID | 20210121113520.3603097-4-gprocida@google.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | BPF |
Headers | show |
Series | Small fixes and improvements | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
Em Thu, Jan 21, 2021 at 11:35:20AM +0000, Giuliano Procida escreveu: > NOTE: Do not apply. I will try to eliminate the dependency on objcopy > instead and achieve what's needed directly using libelf. Ok, so I'll wait for the right fix. Thanks for working on this! - Arnaldo > This is to avoid misaligned access when memory-mapping ELF sections. > > Signed-off-by: Giuliano Procida <gprocida@google.com> > --- > libbtf.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/libbtf.c b/libbtf.c > index 7552d8e..2f12d53 100644 > --- a/libbtf.c > +++ b/libbtf.c > @@ -797,6 +797,14 @@ static int btf_elf__write(const char *filename, struct btf *btf) > goto unlink; > } > > + snprintf(cmd, sizeof(cmd), "%s --set-section-alignment .BTF=16 %s", > + llvm_objcopy, filename); > + if (system(cmd)) { > + /* non-fatal, this is a nice-to-have and it's only supported from LLVM 10 */ > + fprintf(stderr, "%s: warning: failed to align .BTF section in '%s': %d!\n", > + __func__, filename, errno); > + } > + > err = 0; > unlink: > unlink(tmp_fn); > -- > 2.30.0.296.g2bfb1c46d8-goog >
diff --git a/libbtf.c b/libbtf.c index 7552d8e..2f12d53 100644 --- a/libbtf.c +++ b/libbtf.c @@ -797,6 +797,14 @@ static int btf_elf__write(const char *filename, struct btf *btf) goto unlink; } + snprintf(cmd, sizeof(cmd), "%s --set-section-alignment .BTF=16 %s", + llvm_objcopy, filename); + if (system(cmd)) { + /* non-fatal, this is a nice-to-have and it's only supported from LLVM 10 */ + fprintf(stderr, "%s: warning: failed to align .BTF section in '%s': %d!\n", + __func__, filename, errno); + } + err = 0; unlink: unlink(tmp_fn);
NOTE: Do not apply. I will try to eliminate the dependency on objcopy instead and achieve what's needed directly using libelf. This is to avoid misaligned access when memory-mapping ELF sections. Signed-off-by: Giuliano Procida <gprocida@google.com> --- libbtf.c | 8 ++++++++ 1 file changed, 8 insertions(+)