When trying to run the command,
sudo tc filter add dev veth0 egress bpf direct-action obj a.o sec classifier
I'm getting this error,
libbpf: prog 'pdm_main': bad map relo against '.rodata.str1.1' in section '.rodata.str1.1'
ERROR: opening BPF object file failed
Unable to load program
The sections in my object file,
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 0000000000000000 0000000000000000 00000040 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 classifier 00000638 0000000000000000 0000000000000000 00000040 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
2 .maps 00000020 0000000000000000 0000000000000000 00000678 2**3
CONTENTS, ALLOC, LOAD, DATA
3 .rodata.str1.1 0000002c 0000000000000000 0000000000000000 00000698 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rodata.str1.16 00000036 0000000000000000 0000000000000000 000006d0 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 license 00000004 0000000000000000 0000000000000000 00000706 2**0
CONTENTS, ALLOC, LOAD, DATA
6 .debug_loclists 00000105 0000000000000000 0000000000000000 0000070a 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_abbrev 000001c9 0000000000000000 0000000000000000 0000080f 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_info 0000080f 0000000000000000 0000000000000000 000009d8 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
9 .debug_str_offsets 000002a4 0000000000000000 0000000000000000 000011e7 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
10 .debug_str 000006ec 0000000000000000 0000000000000000 0000148b 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
11 .debug_addr 00000030 0000000000000000 0000000000000000 00001b77 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
12 .BTF 00001037 0000000000000000 0000000000000000 00001ba8 2**2
CONTENTS, RELOC, READONLY
13 .BTF.ext 00000470 0000000000000000 0000000000000000 00002be0 2**2
CONTENTS, RELOC, READONLY
14 .eh_frame 00000030 0000000000000000 0000000000000000 00003050 2**3
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
15 .debug_line 00000220 0000000000000000 0000000000000000 00003080 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
16 .debug_line_str 000000f8 0000000000000000 0000000000000000 000032a0 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
How to fix this? When i don't use eBPF map in my code it doesn't give the same error.
I am using this tutorial to analyze the dump file generated on kernel crash.
The dump file is successfully generated and I am able to access it using crash utility.
/* Code for the kernel module */
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/types.h>
static s32 __init testmoduleinit(void)
{
s8 *ptr = NULL;
pr_info("%s:module loaded.\n", __func__);
*ptr = 100; // generate oops
return 0;
}
static void __exit testmoduledeinit(void)
{
pr_info("%s:module un-loaded.\n", __func__);
}
module_init(testmoduleinit);
module_exit(testmoduledeinit);
MODULE_LICENSE("GPL");
The crash logs(backtrace output) are as follows.
crash> bt
PID: 3401 TASK: ffff9d6928b3af00 CPU: 2 COMMAND: "insmod"
#0 [ffffb2bd846478c8] machine_kexec at ffffffff9246fe83
#1 [ffffb2bd84647928] __crash_kexec at ffffffff9255a152
#2 [ffffb2bd846479f8] crash_kexec at ffffffff9255aff1
#3 [ffffb2bd84647a18] oops_end at ffffffff9243633d
#4 [ffffb2bd84647a40] no_context at ffffffff924803c9
#5 [ffffb2bd84647ab0] __bad_area_nosemaphore at ffffffff924807c0
#6 [ffffb2bd84647af8] bad_area_nosemaphore at ffffffff92480976
#7 [ffffb2bd84647b08] __do_page_fault at ffffffff9248133d
#8 [ffffb2bd84647b70] do_page_fault at ffffffff9248162c
#9 [ffffb2bd84647ba0] page_fault at ffffffff93001284
[exception RIP: _MODULE_INIT_START_gencrash+44]
RIP: ffffffffc062b02c RSP: ffffb2bd84647c58 RFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff9d6935c9c8c8 RDI: ffff9d6935c9c8c8
RBP: ffffb2bd84647c60 R8: 0000000000000722 R9: 0000000000000004
R10: ffff9d693219f730 R11: 0000000000000001 R12: ffffffffc062b000
R13: ffff9d693219f730 R14: ffffb2bd84647e68 R15: ffffffffc0628000
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#10 [ffffb2bd84647c68] do_one_initcall at ffffffff9240389a
#11 [ffffb2bd84647ce0] do_init_module at ffffffff92edd493
#12 [ffffb2bd84647d08] load_module at ffffffff92556e1b
#13 [ffffb2bd84647e48] __do_sys_finit_module at ffffffff9255773c
#14 [ffffb2bd84647f20] __x64_sys_finit_module at ffffffff9255777a
#15 [ffffb2bd84647f30] do_syscall_64 at ffffffff92405207
#16 [ffffb2bd84647f50] entry_SYSCALL_64_after_hwframe at ffffffff9300008c
RIP: 00007f7f2613c539 RSP: 00007fff5ba4f6a8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 000056442b32d7c0 RCX: 00007f7f2613c539
RDX: 0000000000000000 RSI: 0000564429214d2e RDI: 0000000000000003
RBP: 0000564429214d2e R8: 0000000000000000 R9: 00007f7f2640f000
R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
R13: 000056442b32d760 R14: 0000000000000000 R15: 0000000000000000
ORIG_RAX: 0000000000000139 CS: 0033 SS: 002b
The "bt" logs show that page fault is generated at address ffffffffc062b02c.
But when I do
crash> mod -s test_module ./test_module.o
crash> sym ffffffffc062b02c
I don't see the line number in source code which is generating crash.
Is there any way to get the line number from the kernel module which is causing the oops condition.
I am running Ubuntu 18.04.2 LTS and trying to build some code using gcc and getting the following error:
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/lib/../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/lib64/libgcc_s.so.1: undefined reference to `memcpy#GLIBC_2.14'
collect2: error: ld returned 1 exit status
I believe that the problem does not lie in the project but the object file that is trying to use a GLIBC version unavailable on my system but is part of my system.
The object file is /usr/x86_64-linux-gnu/lib/crt1.o part of libc6-dev-amd64-cross version 2.27-3ubuntu1cross1.1.
I am not too familiar with gcc and it seems that I cannot just pull a libc 2.14 and get it to build.
I am stuck.
What should I check? Do I need to use an option for gcc? Or perhaps is this a problem in my distribution?
More info:
# readlink -f /usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/lib/../lib/crt1.o
/usr/x86_64-linux-gnu/lib/crt1.o
# file /usr/x86_64-linux-gnu/lib/crt1.o
/usr/x86_64-linux-gnu/lib/crt1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), for GNU/Linux 3.2.0, not stripped
# apt-file search /usr/x86_64-linux-gnu/lib/crt1.o
libc6-dev-amd64-cross: /usr/x86_64-linux-gnu/lib/crt1.o
# dpkg -l | grep libc6-dev-amd64-cross
ii libc6-dev-amd64-cross 2.27-3ubuntu1cross1.1 [...]
# objdump -t /usr/x86_64-linux-gnu/lib/crt1.o
/usr/x86_64-linux-gnu/lib/crt1.o: file format elf64-x86-64
SYMBOL TABLE:
0000000000000000 l d .text 0000000000000000 .text
0000000000000000 l d .note.ABI-tag 0000000000000000 .note.ABI-tag
0000000000000000 l d .rodata.cst4 0000000000000000 .rodata.cst4
0000000000000000 l d .eh_frame 0000000000000000 .eh_frame
0000000000000000 l d .data 0000000000000000 .data
0000000000000000 l d .bss 0000000000000000 .bss
0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack
0000000000000000 *UND* 0000000000000000 __libc_csu_fini
0000000000000030 g F .text 0000000000000002 .hidden _dl_relocate_static_pie
0000000000000000 g F .text 000000000000002b _start
0000000000000000 *UND* 0000000000000000 __libc_csu_init
0000000000000000 *UND* 0000000000000000 main
0000000000000000 w .data 0000000000000000 data_start
0000000000000000 *UND* 0000000000000000 _GLOBAL_OFFSET_TABLE_
0000000000000000 g O .rodata.cst4 0000000000000004 _IO_stdin_used
0000000000000000 *UND* 0000000000000000 __libc_start_main
0000000000000000 g .data 0000000000000000 __data_start
# gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
[...]
# ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
[...]
Edit 1: I have checked out this question but as crt1.o is not an object I compiled but part of a system package installed by Ubuntu, I think I am unable to re-compile it. But I might be wrong, I am not really familiar with gcc.
I'm a bit newbie with RISCV processor and this is really anoying me
I've created a .C program for RISCV using the tutorial here http://riscv.org/download.html#tab_tools at "Testing Your Toolchain".
If I use in my computer
spike pk myhello
I get "Hello world!" as expected but if I run it on mi FPGA using this command
./fesvr-zynq pk myhello
I get
z 0000000000000000 ra 0000000000010030 s0 ffffffffffffffc0
s1 0000000000015290 s2 0000000000000000 s3 0000000000014b60
s4 0000000000014b60 s5 0000000000000000 s6 0000000000000000
s7 0000000000000000 s8 0000000000000000 s9 0000000000010258
sA 0000000000000000 sB 0000000000000000 sp 000000000ff7fb40
tp 0000000000000000 v0 0000000000000000 v1 0000000000000000
a0 0000000000000000 a1 0000000000000000 a2 0000000000000000
a3 0000000000000000 a4 0000000000000000 a5 0000000000000000
a6 0000000000000000 a7 0000000000000000 t0 0000000000000000
t1 0000000000000000 t2 0000000000000000 t3 0000000000000000
t4 0000000000000000 t5 0000000000000000 sr 00000000a00000e9
pc 0000000000010448 va 000007fffffffff0 insn ffffffff
User store segfault # 0x000007fffffffff0
Instead getting "hello world!" like the included example in the precompiled-image at SDCARD.
I've tried to boot linux but I can't send my program to the FPGA when the OS is launched.
Thanks a lot
As pointed by user2548418, updating "pk" package solved the problem (and creating again the image with it inside).
Copying files with scp when linux kernel is booted is not currently available, but they can be loaded into the system following the instructions at "Creating a Root Disk Image" in RISCV tools, copying the files into the folders created by mkdir.
I'm trying to emulate freescale powerpc with QEMU,but faced some problem.
When I try to run ppc u-boot,it fails with the infomation below:
$ qemu-system-ppc -M ppce500 -nographic -kernel u-boot
qemu: fatal: Trying to execute code outside RAM or ROM at 0xeff40000
NIP eff40000 LR 00000000 CTR 00000000 XER 00000000
MSR 00000000 HID0 00000000 HF 00000000 idx 1
TB 00000000 05858550 DECR 00000000
GPR00 0000000000000000 0000000000fffff8 0000000000000000 00000000f1800000
GPR04 0000000000000000 0000000000000000 0000000045504150 0000000000000000
GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
CR 00000000 [ - - - - - - - - ] RES ffffffff
FPR00 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
FPSCR 00000000
SRR0 00000000 SRR1 00000000 PVR 80210030 VRSAVE 00000000
SPRG0 00000000 SPRG1 00000000 SPRG2 00000000 SPRG3 00000000
SPRG4 00000000 SPRG5 00000000 SPRG6 00000000 SPRG7 00000000
CSRR0 00000000 CSRR1 00000000 MCSRR0 00000000 MCSRR1 00000000
TCR 00000000 TSR 00000000 ESR 00000000 DEAR 00000000
PIR 00000000 DECAR 00000000 IVPR 00000000 EPCR 00000000
MCSR 00000000 SPRG8 00000000 EPR 00000000
MCAR 00000000 PID1 00000000 PID2 00000000 SVR 00000000
MAS0 00000000 MAS1 00000000 MAS2 00000000 MAS3 00000000
MAS4 00000000 MAS6 00000000 MAS7 00000000 PID 00000000
MMUCFG 00000000 TLB0CFG 04110200 TLB1CFG 101cc010
[1] 13621 abort (core dumped) qemu-system-ppc -M ppce500 -nographic -kernel u-boot
As the error message shows: qemu: fatal: Trying to execute code outside RAM or ROM at 0xeff40000.It's Strange.The u-boot I tried is ok on powerpc e500 board.What's more,I have run powerpc linux kernel successfully whih qemu-system-ppc.
The version of my qemu is the latest 2.3.50, and I've tried 1.7 have the same problem.
Is there anybody faced the same problem?
There was a bug in 2.3.50 (bugreport) with this effect.
It has been fixed in more recent qemu releases.
Why it breaks in v1.7, I don't know. (are you sure?)