> > The ELF_ARCH was defined as 39 inside linux kernel(before 4.20), so > > the the core file generated was EM_RCE. > > I'v regenerated the core file with ELF_ARCH defined as 252: > > https://github.com/c-sky/test-result/blob/master/elfutils/zeroptr > > https://github.com/c-sky/test-result/raw/master/elfutils/core.zeroptr > > We have extended our core dump reg set last year, linux kernel have > > upstreamed this change, but the gdb does not. I'v only got an old > > released toolchain(EM_RCE) and the upstream toolchain(out of date > > reg set) in my enviroment, so I can't generate/verify EM_CSKY core > > file with any toolchain I have. > > So the zeroptr binary looks correct now. > But the core.zeroptr is probably generated by an older linux kernel and > still is EM_RCE. This confusion is a bit confusing since I makes it > really hard to check the details (register numbering, etc.) are really > correct. I can tweak the code a bit to accept EM_RCE as EM_CSKY but > then the PRSTATUS core note doesn't look correct. I am not sure that is > because the register set as dumped by the kernel is bogus or because > the prstatus_regs definition in csky_corenote.c is incorrect.
vmh@vmh-VirtualBox:~/workspace/test-result/elfutils$ file core.zeroptr core.zeroptr: ELF 32-bit LSB core file *unknown arch 0xfc* version 1 (SYSV), SVR4-style, from 'root/zeroptr' The core.zeroptr should be EM_CSKY now. I've tested the core file with non-public released toolchain with EM_CSKY(the upstream gdb don't support csky coredump). GPR seems loaded correctly. I think the prstatus_regs have the correct reg size (36 * 4), problem may come from the coredump regs->dwarf regs mapping(the mapping and coredump support for binutil is not upsteamed). https://github.com/c-sky/binutils-gdb/blob/fecb9cfcf9ac6e43ec2d971ce064fbb2dccb0847/gdb/csky-tdep.c: /* Offset mapping table from core_section to regcache of general registers for ck810. */ static int csky_gregset_offset_v2[] = { 72, 1, 0, 89, 2, /* pc, r1, r0, psr, r2. */ 3, 4, 5, 6, 7, /* r3 ~ r32. */ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }; /home/vmh/workspace/buildroot2/buildroot/output/host/bin/csky-linux-gdb zeroptr /home/vmh/workspace/buildroot2/buildroot/output/host/bin/csky-linux-gdb: warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration of GDB. Attempting to continue with the default csky settings. GNU gdb (GDB) 7.12 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=x86_64-pc-linux-gnu --target=csky-buildroot-linux-gnuabiv2". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration of GDB. Attempting to continue with the default csky settings. Reading symbols from zeroptr...done. (cskygdb) core-file core.zeroptr [New process 143] Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00000000 in ?? () (cskygdb) i r r0 0x1 1 r1 0x7fbbce24 2143014436 r2 0x0 0 r3 0x0 0 r4 0xc4430 803888 r5 0x0 0 r6 0x0 0 r7 0x8bfc 35836 r8 0x7fbbcd50 2143014224 r9 0xc4430 803888 r10 0xc43ec 803820 r11 0xc4190 803216 r12 0xf946246b -112843669 r13 0x1b81c 112668 r14 0x7fbbcd4c 0x7fbbcd4c r15 0x8656 34390 r16 0xc443c 803900 r17 0xffffffff -1 r18 0x67180 422272 r19 0xffffffff -1 r20 0x2f2f2f2f 791621423 r21 0x0 0 r22 0x1000 4096 r23 0x0 0 r24 0x0 0 r25 0x663ac 418732 r26 0x2ab56f50 716533584 r27 0x0 0 r28 0x2abecbd8 717147096 r29 0x0 0 r30 0x0 0 r31 0x68478 427128 pc 0x0 0x0 epc <unavailable> psr 0x140340 1311552 epsr <unavailable> > > These attributes including cpu name and some other ISA related > > descriptions. > > Some thing like: > > CSKY_ARCH_NAME: "ck810" > > CSKY_CPU_NAME: "ck810f" > > CSKY_ISA_FLAG: 0x12345678 > > CSKY_ISA_EXT_FLAG: 5 > > They are not documented yet. > > I'v ask the person who is responsible for these to update the ABI > > documents, but I think it will take a quite long time for them to > > do that. They are quite busy at present. > > OK. If you can add that tweak to src/readelf.c and add an > check_object_attribute hook that handles the above attributes that > would be good. > > Ideally you also add a testcase for tests/readelf-A.sh > Some of those tests cheat and create the attributes by hand. > But it would be nice if you could generate a small .o file with the > latest toolchain to be used as testcase in some other tests. I'm not sure about how to handle different data type here. It seems only tag_name is required when data type is string, I could not found how to handle int here. The binary with csky.attribute currently can not be generate with public released toolchain, so I don't know how to add the testcase. Tested on x86 ============================================================================ Testsuite summary for elfutils 0.176 ============================================================================ # TOTAL: 209 # PASS: 204 # SKIP: 5 # XFAIL: 0 # FAIL: 0 # XPASS: 0 # ERROR: 0 ============================================================================ Changes since v1: - Add the Signed-off-by line and the copyright Changes since v2: - move changelog to corresponding entries - correct core dump registers size - remove unused fpu DWARF register Changes since v3: - add testfilecsky.bz2 and hello_csky.ko.bz2 - add csky_check_object_attribute Mao Han (1): Add backend support for C-SKY backends/ChangeLog | 12 ++++++ backends/Makefile.am | 9 ++++- backends/csky_attrs.c | 67 +++++++++++++++++++++++++++++++ backends/csky_cfi.c | 60 ++++++++++++++++++++++++++++ backends/csky_corenote.c | 61 ++++++++++++++++++++++++++++ backends/csky_init.c | 65 ++++++++++++++++++++++++++++++ backends/csky_initreg.c | 87 ++++++++++++++++++++++++++++++++++++++++ backends/csky_regs.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++ backends/csky_reloc.def | 86 ++++++++++++++++++++++++++++++++++++++++ backends/csky_symbol.c | 77 ++++++++++++++++++++++++++++++++++++ libebl/ChangeLog | 4 ++ libebl/eblopenbackend.c | 1 + src/ChangeLog | 4 ++ src/elflint.c | 2 +- src/readelf.c | 4 +- tests/ChangeLog | 7 ++++ tests/hello_csky.ko.bz2 | Bin 0 -> 26448 bytes tests/run-addrcfi.sh | 43 ++++++++++++++++++++ tests/run-strip-reloc.sh | 3 +- tests/testfilecsky.bz2 | Bin 0 -> 3145 bytes 20 files changed, 688 insertions(+), 5 deletions(-) create mode 100644 backends/csky_attrs.c create mode 100644 backends/csky_cfi.c create mode 100644 backends/csky_corenote.c create mode 100644 backends/csky_init.c create mode 100644 backends/csky_initreg.c create mode 100644 backends/csky_regs.c create mode 100644 backends/csky_reloc.def create mode 100644 backends/csky_symbol.c create mode 100644 tests/hello_csky.ko.bz2 create mode 100644 tests/testfilecsky.bz2 -- 2.7.4