Skip to content

Commit f4f25b6

Browse files
committed
Merge branch 'libbpf-extend-linker-api-to-support-in-memory-elf-files'
Alastair Robertson says: ==================== libbpf: Extend linker API to support in-memory ELF files This gives API consumers the option of using anonymous files/memfds to avoid writing temporary ELFs to disk, which will be useful for performing linking as part of bpftrace's JIT compilation. v3: - Removed "filename" option. Now always generate our own filename for passed-in FDs and buffers. - Use a common function (bpf_linker_add_file) for shared implementation of bpf_linker__add_file, bpf_linker__add_fd and bpf_linker__add_buf. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Andrii Nakryiko <[email protected]>
2 parents b9fee10 + 6d5e5e5 commit f4f25b6

File tree

3 files changed

+182
-53
lines changed

3 files changed

+182
-53
lines changed

tools/lib/bpf/libbpf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,9 +1796,14 @@ struct bpf_linker_file_opts {
17961796
struct bpf_linker;
17971797

17981798
LIBBPF_API struct bpf_linker *bpf_linker__new(const char *filename, struct bpf_linker_opts *opts);
1799+
LIBBPF_API struct bpf_linker *bpf_linker__new_fd(int fd, struct bpf_linker_opts *opts);
17991800
LIBBPF_API int bpf_linker__add_file(struct bpf_linker *linker,
18001801
const char *filename,
18011802
const struct bpf_linker_file_opts *opts);
1803+
LIBBPF_API int bpf_linker__add_fd(struct bpf_linker *linker, int fd,
1804+
const struct bpf_linker_file_opts *opts);
1805+
LIBBPF_API int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz,
1806+
const struct bpf_linker_file_opts *opts);
18021807
LIBBPF_API int bpf_linker__finalize(struct bpf_linker *linker);
18031808
LIBBPF_API void bpf_linker__free(struct bpf_linker *linker);
18041809

tools/lib/bpf/libbpf.map

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,8 @@ LIBBPF_1.5.0 {
432432
} LIBBPF_1.4.0;
433433

434434
LIBBPF_1.6.0 {
435+
global:
436+
bpf_linker__add_buf;
437+
bpf_linker__add_fd;
438+
bpf_linker__new_fd;
435439
} LIBBPF_1.5.0;

0 commit comments

Comments
 (0)