netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: ast@fb.com
Cc: daniel@iogearbox.net, aconole@bytheb.org, netdev@vger.kernel.org,
	xdp-newbies@vger.kernel.org
Subject: Re: [PATCH v3 binutils] Add BPF support to binutils...
Date: Sat, 29 Apr 2017 22:24:50 -0400 (EDT)	[thread overview]
Message-ID: <20170429.222450.1300920007783667009.davem@davemloft.net> (raw)
In-Reply-To: <9d5e3a87-15d0-01d7-6272-fa8d2bf0d076@fb.com>

From: Alexei Starovoitov <ast@fb.com>
Date: Sat, 29 Apr 2017 17:48:43 -0700

> $ bld/binutils/objdump -S test.o
> 
> test.o:     file format elf64-bpfbe
> 
> Disassembly of section .text:
> 
> 0000000000000000 <bpf_prog1>:
>    0:	18 10 00 00 83 98 47 39 	ldimm64	r1, 590618314553
>    8:	00 00 00 00 00 00 00 89
>   10:	7b a1 ff f8 00 00 00 00 	stdw	[r10+65528], r1
>   18:	79 1a ff f8 00 00 00 00 	lddw	r1, [r10+65528]
>   20:	07 10 00 00 8f ff 00 02 	add	r1, -1879113726
>   28:	79 01 00 00 00 00 00 00 	lddw	r0, [r1+0]
>   30:	95 00 00 00 00 00 00 00 	exit
> 
> looks good except negative offsets are reported as large positive.

Some of your bugs should be fixed by this patch below, I'll add
test cases soon:

diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c
index 0ba2afa..36393b7 100644
--- a/gas/config/tc-bpf.c
+++ b/gas/config/tc-bpf.c
@@ -288,6 +288,14 @@ md_assemble (char *str ATTRIBUTE_UNUSED)
 	  switch (*args)
 	    {
 	    case '+':
+	      if (*s == '+')
+		{
+		  ++s;
+		  continue;
+		}
+	      if (*s == '-')
+		continue;
+	      break;
 	    case ',':
 	    case '[':
 	    case ']':
diff --git a/opcodes/bpf-dis.c b/opcodes/bpf-dis.c
index 92e29af..39656bf 100644
--- a/opcodes/bpf-dis.c
+++ b/opcodes/bpf-dis.c
@@ -49,7 +49,7 @@ print_insn_bpf (bfd_vma memaddr, disassemble_info *info)
   bpf_opcode_hash *op;
   int code, dest, src;
   bfd_byte buffer[8];
-  unsigned short off;
+  signed short off;
   int status, ret;
   signed int imm;
 
@@ -78,7 +78,7 @@ print_insn_bpf (bfd_vma memaddr, disassemble_info *info)
   else
     {
       getword = bfd_getl32;
-      gethalf = bfd_getl32;
+      gethalf = bfd_getl16;
     }  
 
   code = buffer[0];
@@ -128,7 +128,7 @@ print_insn_bpf (bfd_vma memaddr, disassemble_info *info)
 	      (*info->fprintf_func) (stream, "%d", imm);
 	      break;
 	    case 'O':
-	      (*info->fprintf_func) (stream, "%d", off);
+	      (*info->fprintf_func) (stream, "%d", (int) off);
 	      break;
 	    case 'L':
 	      info->target = memaddr + ((off - 1) * 8);

  parent reply	other threads:[~2017-04-30  2:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 20:33 [PATCH v3 binutils] Add BPF support to binutils David Miller
2017-04-30  0:48 ` Alexei Starovoitov
2017-04-30  2:11   ` David Miller
2017-04-30  2:13   ` David Miller
2017-04-30  2:24     ` Alexei Starovoitov
2017-04-30  2:24   ` David Miller [this message]
2017-04-30  2:37     ` David Miller
2017-04-30  6:44       ` Alexei Starovoitov
2017-04-30 15:28         ` David Miller
2017-04-30 15:40         ` David Miller
2017-04-30 18:21         ` David Miller
2017-05-02  2:49           ` Alexei Starovoitov
2017-05-02  3:03             ` David Miller
2017-05-02  3:14               ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170429.222450.1300920007783667009.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=aconole@bytheb.org \
    --cc=ast@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=xdp-newbies@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).