Message ID | 20190817005056.15749-4-jose.marchesi@oracle.com |
---|---|
State | New |
Headers | show |
Series | eBPF support for GCC | expand |
On 8/16/19 6:50 PM, Jose E. Marchesi wrote: > This patch adds an eBPF port to libgcc. > > As of today, compiled eBPF programs do not support a single-entry > point schema. Instead, a BPF "executable" is a relocatable ELF object > file containing multiple entry points, in certain named sections. > > Also, the BPF loaders in the kernel do not execute .ini/.fini > constructors/destructors. Therefore, this patch provides empty crtn.S > and cri.S files. > > libgcc/ChangeLog: > > * config.host: Set cpu_type for bpf-*-* targets. > * config/bpf/t-bpf: Likewise. > * config/bpf/crtn.S: Likewise. > * config/bpf/crti.S: New file. > diff --git a/libgcc/config/bpf/crti.S b/libgcc/config/bpf/crti.S > new file mode 100644 > index 00000000000..e69de29bb2d > diff --git a/libgcc/config/bpf/crtn.S b/libgcc/config/bpf/crtn.S > new file mode 100644 > index 00000000000..e69de29bb2d > diff --git a/libgcc/config/bpf/t-bpf b/libgcc/config/bpf/t-bpf > new file mode 100644 > index 00000000000..c1bda7c98cb > --- /dev/null > +++ b/libgcc/config/bpf/t-bpf > @@ -0,0 +1,24 @@ > +HOST_LIBGCC2_CFLAGS += -O0 > +LIB2ADDEH = I'd like to understand the motivation behind the -O0, but otherwise I don't see anything particularly concerning here. Jeff
Hi Jeff. First of all, thanks for reviewing the port. > +++ b/libgcc/config/bpf/t-bpf > @@ -0,0 +1,24 @@ > +HOST_LIBGCC2_CFLAGS += -O0 > +LIB2ADDEH = I'd like to understand the motivation behind the -O0, but otherwise I don't see anything particularly concerning here. Oh that's a reminiscency from earlier development stages when libgcc wouldn't built with -O2. I just removed it and everything builds ok.
diff --git a/libgcc/config.host b/libgcc/config.host index 503ebb6be20..2e9fbc35482 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -107,6 +107,9 @@ avr-*-*) bfin*-*) cpu_type=bfin ;; +bpf-*-*) + cpu_type=bpf + ;; cr16-*-*) ;; crisv32-*-*) @@ -526,6 +529,10 @@ bfin*-*) tmake_file="$tmake_file bfin/t-bfin t-fdpbit" extra_parts="crtbegin.o crtend.o crti.o crtn.o" ;; +bpf-*-*) + tmake_file="$tmake_file ${cpu_type}/t-${cpu_type}" + extra_parts="crti.o crtn.o" + ;; cr16-*-elf) tmake_file="${tmake_file} cr16/t-cr16 cr16/t-crtlibid t-fdpbit" extra_parts="$extra_parts crti.o crtn.o crtlibid.o" diff --git a/libgcc/config/bpf/crti.S b/libgcc/config/bpf/crti.S new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgcc/config/bpf/crtn.S b/libgcc/config/bpf/crtn.S new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgcc/config/bpf/t-bpf b/libgcc/config/bpf/t-bpf new file mode 100644 index 00000000000..c1bda7c98cb --- /dev/null +++ b/libgcc/config/bpf/t-bpf @@ -0,0 +1,24 @@ +HOST_LIBGCC2_CFLAGS += -O0 +LIB2ADDEH = + +crti.o: $(srcdir)/config/bpf/crti.S + $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< + +crtn.o: $(srcdir)/config/bpf/crtn.S + $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< + +# Some of the functions defined in libgcc2 exceed the eBPF stack +# limit, or other restrictions imposed by this peculiar target. +# Therefore we have to exclude them here. +# +# Patterns in bpf.md must guarantee that no calls to the excluded +# functions are ever generated, and compiler tests should make sure +# this holds. +# +# Note that the modes in the function names below are misleading: di +# means TImode. +LIB2FUNCS_EXCLUDE = _mulvdi3 _divdi3 _moddi3 _divmoddi4 _udivdi3 _umoddi3 \ + _udivmoddi4 + +# Prevent building "advanced" stuff (for example, gcov support). +INHIBIT_LIBC_CFLAGS = -Dinhibit_libc