public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [[RESEND & PING]PATCH V3 0/1] Add C-SKY support
@ 2019-06-03  8:17 Mao Han
  2019-06-03  8:19 ` [[RESEND & PING]PATCH V3 1/1] Add backend support for C-SKY Mao Han
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Mao Han @ 2019-06-03  8:17 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mao Han, Mark Wielaard

CC: Mark Wielaard <mark@klomp.org>

This patch add backend support for C-SKY architecture.

FAIL cases on csky:
1. run-backtrace-*
discussed in this thread before, seems can't support with current
core_set_initial_registers.
https://sourceware.org/ml/elfutils-devel/2019-q2/msg00021.html
test binary:
https://github.com/c-sky/test-result/blob/master/elfutils/divzero
https://github.com/c-sky/test-result/blob/master/elfutils/core

2. run-native-test.sh
ssh script problem, can pass if it is ran directly.

3. run-dwarf-getmacros.sh
ssh script problem, the empty string argument is lose,
can pass if it is ran directly.

4. run-deleted.sh
ssh script problem, can pass if it is ran directly.

5. run-reverse-sections-self.sh
elfcopy --reverse-offs dose not work properly on C-SKY object file,
seems not related to arch specific code.
size.o before copy:
https://github.com/c-sky/test-result/blob/master/elfutils/size.o
size.o.rev after copy:
https://github.com/c-sky/test-result/blob/master/elfutils/size.o.rev

Tested on x86:
============================================================================
Testsuite summary for elfutils 0.176
============================================================================
# TOTAL: 207
# PASS:  203
# SKIP:  4
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================

Tested with ssh on C-SKY:
==========================================
   elfutils 0.176: tests/test-suite.log
==========================================

# TOTAL: 207
# PASS:  198
# SKIP:  5
# XFAIL: 0
# FAIL:  4
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

SKIP: run-readelf-compressed.sh
===============================

elfutils built without bzip2 support
SKIP run-readelf-compressed.sh (exit status: 77)

FAIL: run-native-test.sh
========================

allregs: 11615: No such file or directory
FAIL run-native-test.sh (exit status: 1)

FAIL: run-dwarf-getmacros.sh
============================

--- dwarf-getmacros.out	2019-05-29 18:10:03.896561841 +0800
+++ /tmp/123	2019-05-29 18:10:02.364561841 +0800
@@ -1 +1,4 @@
-invalid opcode
+opcode 255 with 0 arguments
+file /home/petr/proj/elfutils/master/elfutils/x.c
+ FOO 0
+/file
FAIL run-dwarf-getmacros.sh (exit status: 1)

SKIP: run-backtrace-data.sh
===========================

/home/vmh/workspace/elfutils/tests/backtrace-data: x86_64 linux only test
SKIP run-backtrace-data.sh (exit status: 77)

SKIP: run-backtrace-native-biarch.sh
====================================

biarch testing disabled
SKIP run-backtrace-native-biarch.sh (exit status: 77)

SKIP: run-backtrace-native-core.sh
==================================

Aborted
No core.4784 file generated
SKIP run-backtrace-native-core.sh (exit status: 77)

SKIP: run-backtrace-native-core-biarch.sh
=========================================

biarch testing disabled
SKIP run-backtrace-native-core-biarch.sh (exit status: 77)

FAIL: run-deleted.sh
====================

PID 5007 - process
TID 5007:
#0  0x2ab71846 __nanosleep
#1  0x2ab716e8 sleep
#2  0x2aacc6b0
/home/vmh/workspace/elfutils/src/stack: dwfl_thread_getframes tid 5007 at 0x2aacc6af in /home/vmh/workspace/elfutils/tests/test-13671/deleted-lib.so: Callback returned failure
./run-deleted.sh: line 38: kill: (5007) - No such process
FAIL run-deleted.sh (exit status: 1)

FAIL: run-reverse-sections-self.sh
==================================


copy_elf: /home/vmh/workspace/elfutils/src/addr2line -> addr2line.rev (read,reverse)
setshstrndx: 35
Swapping offsets of section 24 and 25
Swapping offsets of section 28 and 29
Swapping offsets of section 32 and 33
Swapping offsets of section 34 and 35
No errors
elfrdwrdnop addr2line.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/src/elfcmp -> elfcmp.rev (read,reverse)
setshstrndx: 36
Swapping offsets of section 25 and 26
Swapping offsets of section 29 and 30
Swapping offsets of section 33 and 34
Swapping offsets of section 35 and 36
No errors
elfrdwrdnop elfcmp.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/src/objdump -> objdump.rev (read,reverse)
setshstrndx: 36
Swapping offsets of section 25 and 26
Swapping offsets of section 29 and 30
Swapping offsets of section 33 and 34
Swapping offsets of section 35 and 36
No errors
elfrdwrdnop objdump.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/src/readelf -> readelf.rev (read,reverse)
setshstrndx: 36
Swapping offsets of section 25 and 26
Swapping offsets of section 29 and 30
Swapping offsets of section 33 and 34
Swapping offsets of section 35 and 36
No errors
elfrdwrdnop readelf.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/libelf/libelf.so -> libelf.so.rev (read,reverse)
setshstrndx: 36
Swapping offsets of section 25 and 26
Swapping offsets of section 28 and 29
Swapping offsets of section 30 and 31
Swapping offsets of section 33 and 34
Swapping offsets of section 35 and 36
No errors
elfrdwrdnop libelf.so.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/libdw/libdw.so -> libdw.so.rev (read,reverse)
setshstrndx: 36
Swapping offsets of section 25 and 26
Swapping offsets of section 28 and 29
Swapping offsets of section 30 and 31
Swapping offsets of section 33 and 34
Swapping offsets of section 35 and 36
No errors
elfrdwrdnop libdw.so.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/backends/libebl_i386.so -> libebl_i386.so.rev (read,reverse)
setshstrndx: 34
Swapping offsets of section 23 and 24
Swapping offsets of section 26 and 27
Swapping offsets of section 28 and 29
Swapping offsets of section 31 and 32
Swapping offsets of section 33 and 34
No errors
elfrdwrdnop libebl_i386.so.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/backends/libebl_x86_64.so -> libebl_x86_64.so.rev (read,reverse)
setshstrndx: 34
Swapping offsets of section 23 and 24
Swapping offsets of section 26 and 27
Swapping offsets of section 28 and 29
Swapping offsets of section 31 and 32
Swapping offsets of section 33 and 34
No errors
elfrdwrdnop libebl_x86_64.so.rev
No errors

copy_elf: /home/vmh/workspace/elfutils/src/size.o -> size.o.rev (read,reverse)
setshstrndx: 29
Swapping offsets of section 13 and 14
Swapping offsets of section 22 and 23
Swapping offsets of section 28 and 29
/home/vmh/workspace/elfutils/src/elfcmp: /home/vmh/workspace/elfutils/src/size.o size.o.rev differ: section [1], [1] name
FAIL run-reverse-sections-self.sh (exit status: 1)

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

Mao Han (1):
  Add backend support for C-SKY

 backends/ChangeLog       |  11 ++++++
 backends/Makefile.am     |   9 ++++-
 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 +-
 13 files changed, 565 insertions(+), 3 deletions(-)
 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

-- 
2.7.4

^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [[RESEND & PING]PATCH V3 1/1] Add backend support for C-SKY
@ 2019-07-15  8:56 Mao Han
  2019-07-15 21:44 ` Mark Wielaard
  0 siblings, 1 reply; 14+ messages in thread
From: Mao Han @ 2019-07-15  8:56 UTC (permalink / raw)
  To: mark; +Cc: elfutils-devel

Hi Mark,
I can't find the origin mail thread in my mailbox, as my mutt can only 
keep the newest 5000 mails. So I just reply in a new thread.

> > I've generated binaries/core with an upstream toolchain, however the
> > divzero testcase doesn't cause any coredump, so I used a zeroptr
> > testcase instead.
> > https://github.com/c-sky/test-result/blob/master/elfutils/zeroptr
> > https://github.com/c-sky/test-result/raw/master/elfutils/core.zeroptr
>
> The zeroptr binary does seem to be a real EM_CSKY one now.
> But the core.zeroptr still seems to be a core file for EM_RCE (or
> EM_MCORE).
>
> I assume the kernel generated the core file and it doesn't yet produce
> real EM_CSKY ELF core files?
>
> If you have any other way to generate a core file (maybe gdb/gcore can
> do it?) that would be really helpful.

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.

> > 5. run-reverse-sections-self.sh
> > elfcopy --reverse-offs dose not work properly on C-SKY object file,
> > seems not related to arch specific code.
> > size.o before copy:
> > https://github.com/c-sky/test-result/blob/master/elfutils/size.o
> > size.o.rev after copy:
> > https://github.com/c-sky/test-result/blob/master/elfutils/size.o.rev
>
> This might be because these files are also EM_RCE instead of EM_CSKY.
> But most likely it was because there was a bug in the testcase.
> Make sure you have commit d08c68 tests: elfcopy --reverse-offs should
> only swap sections next to each other.
>
> It looks like in the original the .csky.attributes and .shstrtab are
> not really next to each other (they have consecutive section numbers,
> but the file offsets are far apart). And that could have fooled the
> original test case.
>
> Please make sure you have the above commit/fix in your tree and see if
> it passes then.

This case can pass with the newest elfutils. I believe it is fixed
with commit d08c68.

> OK.
>
> > +RELOC_TYPE (PCRELIMM8BY4,      REL)
> > +RELOC_TYPE (PCRELIMM11BY2,     REL)
>
> Do we want these two? They seem to be v1 only.
>
> > +RELOC_TYPE (PCREL32,           REL|DYN)
>
> This is probably wanted, but the CPU ABI document has it listed as ??.
>
> > +RELOC_TYPE (PCRELJSR_IMM11BY2, REL)
>
> Also v1 only?
>
> > +RELOC_TYPE (GOTOFF,            REL)
> > +RELOC_TYPE (GOTPC,             REL)
> > +RELOC_TYPE (GOT32,             REL)
> > +RELOC_TYPE (PLT32,             REL)
> > +RELOC_TYPE (ADDRGOT,           REL)
> > +RELOC_TYPE (ADDRPLT,           REL)
>
> v1 only?
>
>
> R_CKCORE_GOTOFF_IMM18 is missing, but it is also missing in elf.h.
>
> > +RELOC_TYPE (GOT_IMM18BY4,      REL)
> > +RELOC_TYPE (PLT_IMM18BY4,      REL)
>
> We can list the v1 variants also, their numbers don't overlap.
> Just checking it is done deliberately. If they can never occur in v2
> ELF binaries I would leave them out.

The content of the ABI manual is quite old, binutils souce code seems
much reliable to refer to. binutils/bfd/elf32-csky.c says,
only three relocations are abiv1 exclusive:
R_CKCORE_PCREL_JSR_IMM11BY2
R_CKCORE_PCREL_IMM8BY4
R_CKCORE_PCREL_IMM11BY2

The following relocations can occur in v2 ELF binaries.
R_CKCORE_PCREL32
R_CKCORE_GOTOFF
R_CKCORE_GOTPC
R_CKCORE_GOT32
R_CKCORE_PLT32
R_CKCORE_ADDRGOT
R_CKCORE_ADDRPLT

R_CKCORE_GOTOFF_IMM18 seems unused at present.

> On Thu, 2019-07-11 at 11:19 +0800, Mao Han wrote:
> > On Thu, Jul 11, 2019 at 12:11:17AM +0200, Mark Wielaard wrote:
> > > As far as I can see this is like a SHT_GNU_ATTRIBUTES or
> > > SHT_ARM_ATTRIBUTES section. If so, you will also want something
> > > like:
> > >
> > > diff --git a/src/readelf.c b/src/readelf.c
> > > index cda7c93..8017dc4 100644
> > > --- a/src/readelf.c
> > > +++ b/src/readelf.c
> > > @@ -3571,7 +3571,9 @@ print_attributes (Ebl *ebl, const GElf_Ehdr
> > > *ehdr)
> > >
> > >        if (shdr == NULL || (shdr->sh_type != SHT_GNU_ATTRIBUTES
> > >                            && (shdr->sh_type != SHT_ARM_ATTRIBUTES
> > > -                              || ehdr->e_machine != EM_ARM)))
> > > +                              || ehdr->e_machine != EM_ARM)
> > > +                          && (shdr->sh_type != SHT_CSKY_ATTRIBUTES
> > > +                              || ehdr->e_machine != EM_CSKY)))
> > >         continue;
> > >
> > >        printf (gettext ("\
> > >
> > > And then hook check_object_attribute to display any CSKY specific
> > > attribute names/values.
> >
> > Ok, I'll add check for C-SKY here.
>
> BTW. I couldn't find what generates the SHT_CSKY_ATTRIBUTES or what the
> defined attribute constants are. Are they documented somewhere?

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.

Thanks,
Mao Han

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-07-15 21:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03  8:17 [[RESEND & PING]PATCH V3 0/1] Add C-SKY support Mao Han
2019-06-03  8:19 ` [[RESEND & PING]PATCH V3 1/1] Add backend support for C-SKY Mao Han
2019-07-10 22:11   ` Mark Wielaard
2019-07-11  3:20     ` Mao Han
2019-07-14 21:03       ` Mark Wielaard
2019-07-12 22:10   ` Mark Wielaard
2019-07-10 21:33 ` [[RESEND & PING]PATCH V3 0/1] Add C-SKY support Mark Wielaard
2019-07-11  3:13   ` Mao Han
2019-07-11 13:36     ` Mark Wielaard
2019-07-12 11:24       ` Mao Han
2019-07-12 21:20         ` Mark Wielaard
2019-07-12 21:49 ` Mark Wielaard
2019-07-15  8:56 [[RESEND & PING]PATCH V3 1/1] Add backend support for C-SKY Mao Han
2019-07-15 21:44 ` Mark Wielaard

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).