public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-9762] bpf: allow BSS symbols to be global symbols
@ 2021-04-23 17:20 David Faust
0 siblings, 0 replies; only message in thread
From: David Faust @ 2021-04-23 17:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cc2416801e07b4f6950b4a7d374e57329999bc74
commit r10-9762-gcc2416801e07b4f6950b4a7d374e57329999bc74
Author: YiFei Zhu <zhuyifei1999@gmail.com>
Date: Thu Apr 22 05:05:57 2021 -0500
bpf: allow BSS symbols to be global symbols
Prior to this, a BSS declaration such as:
int foo;
static int bar;
Generates:
.global foo
.local foo
.comm foo,4,4
.local bar
.comm bar,4,4
Creating symbols:
0000000000000000 b foo
0000000000000004 b bar
Both symbols are local. However, libbpf bpf_object__variable_offset
rquires symbols to be STB_GLOBAL & STT_OBJECT for data section lookup.
This patch makes the same declaration generate:
.global foo
.type foo, @object
.lcomm foo,4,4
.local bar
.comm bar,4,4
Creating symbols:
0000000000000000 B foo
0000000000000004 b bar
And libbpf will be okay with looking up the global symbol "foo".
2021-04-22 YiFei Zhu <zhuyifei1999@gmail.com>
gcc/
* config/bpf/bpf.h (ASM_OUTPUT_ALIGNED_BSS): Use .type and .lcomm.
(cherry picked from commit 886b6c1e8af502b69e3f318b9830b73b88215878)
Diff:
---
gcc/config/bpf/bpf.h | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h
index 01e30b7e60e..88183e69564 100644
--- a/gcc/config/bpf/bpf.h
+++ b/gcc/config/bpf/bpf.h
@@ -422,9 +422,15 @@ enum reg_class
Try to use asm_output_aligned_bss to implement this macro. */
#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
- do { \
- ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
- } while (0)
+ do \
+ { \
+ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
+ fprintf ((FILE), "%s", "\t.lcomm\t"); \
+ assemble_name ((FILE), (NAME)); \
+ fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n", \
+ (SIZE), (ALIGN) / BITS_PER_UNIT); \
+ } \
+ while (0)
/*** Output and Generation of Labels. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-23 17:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 17:20 [gcc r10-9762] bpf: allow BSS symbols to be global symbols David Faust
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).