+2018-06-16 Yonghong Song <yhs@fb.com>
+
+ * Makefile.am (bpf_SRCS): Add bpf_symbol.c.
+ * bpf_init.c (bpf_init): Add reloc_simple_type HOOK.
+ * bpf_reloc.def: Add RELOC_TYPE 64_64 and 64_32.
+ * bpf_symbol.c: New file.
+
2018-06-21 Mark Wielaard <mark@klomp.org>
* bpf_reloc.def: Remove MAP_FD.
# an issue.
m68k_corenote_no_Wpacked_not_aligned = yes
-bpf_SRCS = bpf_init.c bpf_regs.c
+bpf_SRCS = bpf_init.c bpf_regs.c bpf_symbol.c
cpu_bpf = ../libcpu/libcpu_bpf.a
libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
bpf_init_reloc (eh);
HOOK (eh, register_info);
HOOK (eh, disasm);
+ HOOK (eh, reloc_simple_type);
return MODVERSION;
}
/* NAME, REL|EXEC|DYN */
RELOC_TYPE (NONE, EXEC|DYN)
+RELOC_TYPE (64_64, REL)
+RELOC_TYPE (64_32, REL)
--- /dev/null
+/* BPF specific symbolic name handling.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <assert.h>
+#include <elf.h>
+#include <stddef.h>
+#include <string.h>
+
+#define BACKEND bpf_
+#include "libebl_CPU.h"
+
+
+/* Check for the simple reloc types. */
+Elf_Type
+bpf_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+{
+ switch (type)
+ {
+ case R_BPF_64_64:
+ return ELF_T_XWORD;
+ case R_BPF_64_32:
+ return ELF_T_WORD;
+ default:
+ return ELF_T_NUM;
+ }
+}
+2018-06-16 Yonghong Song <yhs@fb.com>
+
+ * run-reloc-bpf.sh: New test.
+ * testfile-bpf-reloc.o.bz2: New test file.
+ * testfile-bpf-reloc.expect.bz2: New test file.
+ * Makefile.am (TESTS): Add run-reloc-bpf.sh.
+ (EXTRA_DIST): Add run-reloc-bpf.sh, testfile-bpf-reloc.o.bz2 and
+ testfile-bpf-reloc.expect.bz2.
+
2018-06-13 Mark Wielaard <mark@klomp.org>
* run-readelf-const-values.sh: New test.
run-dwarf-die-addr-die.sh \
run-get-units-invalid.sh run-get-units-split.sh \
run-attr-integrate-skel.sh \
- run-all-dwarf-ranges.sh run-unit-info.sh
+ run-all-dwarf-ranges.sh run-unit-info.sh \
+ run-reloc-bpf.sh
if !BIARCH
export ELFUTILS_DISABLE_BIARCH = 1
run-zstrptr.sh run-compress-test.sh \
run-disasm-bpf.sh \
testfile-bpf-dis1.expect.bz2 testfile-bpf-dis1.o.bz2 \
+ run-reloc-bpf.sh \
+ testfile-bpf-reloc.expect.bz2 testfile-bpf-reloc.o.bz2 \
testfile-m68k-core.bz2 testfile-m68k.bz2 testfile-m68k-s.bz2 \
run-dwarf-die-addr-die.sh \
run-get-units-invalid.sh run-get-units-split.sh \
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2018 Facebook, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# This test file is created with
+# $ cat t.c
+# struct tt {
+# int a;
+# char b;
+# };
+# int test(struct tt *t) {
+# return t->a;
+# }
+# $ clang -O2 -g -emit-llvm -c t.c -o - | llc -march=bpf -filetype=obj -o t.o
+# $ mv t.o testfile-bpf-reloc.o
+
+testfiles testfile-bpf-reloc.o testfile-bpf-reloc.expect
+testrun_compare ${abs_top_builddir}/src/objdump -r testfile-bpf-reloc.o < testfile-bpf-reloc.expect