[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] objdump patch
From: |
gouy yann |
Subject: |
Re: [avr-gcc-list] objdump patch |
Date: |
Mon, 6 Sep 2004 21:43:19 +0200 (CEST) |
Hello,
having the symbols is definitively a good idea.
by the way, since you ask, I would have prefered:
20c: 02 c0 rjmp .+4 ;
0x212 <.do_copy_data_start>
it's just my humble opinion.
best regards.
Yann
--- "Svein E. Seldal" <address@hidden> a
écrit :
> Hello
>
> I've grown too annoied by the fact that objdump (-d)
> does not print any
> symbol on code-space references. To be a good
> open-source programmer, I
> have prepared a patch for binutils to fix this. But
> before I even try to
> commit it into gnu binutils, I would like to get
> your feedback on this.
>
> The snippet below shows the changes that I suggest.
> In short:
>
> 20c: 02 c0 rjmp .+4 ;
> 0x212
>
> becomes
>
> 20c: 02 c0 rjmp 0x212
> <.do_copy_data_start> ; .+4
>
>
> Does this look nice? Its downside is that it kind
> of ruins the
> right-aliged row of ';' and makes the output more
> cluttered. But on the
> upside, it proves it faster and simpler to review
> code.
>
> What I really want to discuss is if we do need the
> "; .+4" comment in
> the example above or not. I dont think I will ever
> need that
> information, but I'm humble if anyone else protests.
>
>
> The patch is appended in this mail and can be
> applied with patch:
>
> $ cd binutils-2.15
> $ patch -p0 <avr-binutils-symbprint.diff
>
> It patches cleanly angainst binutils HEAD, 2.15 and
> 2.14 (and maybe older).
>
>
> Regards,
> Svein Seldal
>
>
> Example:
>
>
> 00000202 <__do_copy_data>:
> 202: 11 e0 ldi r17, 0x01
> ; 1
> 204: a0 e0 ldi r26, 0x00
> ; 0
> 206: b1 e0 ldi r27, 0x01
> ; 1
> 208: e0 e2 ldi r30, 0x20
> ; 32
> 20a: f5 e3 ldi r31, 0x35
> ; 53
> 20c: 02 c0 rjmp 0x212
> <.do_copy_data_start>
> ; .+4
>
> 0000020e <.do_copy_data_loop>:
> 20e: 05 90 lpm r0, Z+
> 210: 0d 92 st X+, r0
>
> 00000212 <.do_copy_data_start>:
> 212: ae 31 cpi r26, 0x1E
> ; 30
> 214: b1 07 cpc r27, r17
> 216: d9 f7 brne 0x20e
> <.do_copy_data_loop>
> ; .-10
>
> 00000218 <__do_clear_bss>:
> 218: 11 e0 ldi r17, 0x01
> ; 1
> 21a: ae e1 ldi r26, 0x1E
> ; 30
> 21c: b1 e0 ldi r27, 0x01
> ; 1
> 21e: 01 c0 rjmp 0x222
> <.do_clear_bss_start>
> ; .+2
>
> 00000220 <.do_clear_bss_loop>:
> 220: 1d 92 st X+, r1
>
> 00000222 <.do_clear_bss_start>:
> 222: aa 3f cpi r26, 0xFA
> ; 250
> 224: b1 07 cpc r27, r17
> 226: e1 f7 brne 0x220
> <.do_clear_bss_loop>
> ; .-8
> > ? avr-binutils-symprint.diff
> ? build.avr
> ? build.native
> ? gas/doc/as.info
> Index: opcodes/avr-dis.c
>
===================================================================
> RCS file: /cvs/src/src/opcodes/avr-dis.c,v
> retrieving revision 1.10
> diff -c -3 -p -r1.10 avr-dis.c
> *** opcodes/avr-dis.c 18 Nov 2002 16:54:08 -0000
> 1.10
> --- opcodes/avr-dis.c 6 Sep 2004 14:31:07 -0000
> *************** const struct avr_opcodes_s
> avr_opcodes[]
> *** 43,52 ****
> };
>
> static int avr_operand PARAMS ((unsigned int,
> unsigned int,
> ! unsigned int, int, char *, char *, int));
>
> static int
> ! avr_operand (insn, insn2, pc, constraint, buf,
> comment, regs)
> unsigned int insn;
> unsigned int insn2;
> unsigned int pc;
> --- 43,52 ----
> };
>
> static int avr_operand PARAMS ((unsigned int,
> unsigned int,
> ! unsigned int, int, char *, char *, int, int *,
> bfd_vma *));
>
> static int
> ! avr_operand (insn, insn2, pc, constraint, buf,
> comment, regs, sym, sym_addr)
> unsigned int insn;
> unsigned int insn2;
> unsigned int pc;
> *************** avr_operand (insn, insn2, pc,
> constraint
> *** 54,61 ****
> --- 54,64 ----
> char *buf;
> char *comment;
> int regs;
> + int *sym;
> + bfd_vma *sym_addr;
> {
> int ok = 1;
> + *sym = 0;
>
> switch (constraint)
> {
> *************** avr_operand (insn, insn2, pc,
> constraint
> *** 145,167 ****
> break;
>
> case 'h':
> ! sprintf (buf, "0x%x",
> ! ((((insn & 1) | ((insn & 0x1f0) >> 3)) <<
> 16) | insn2) * 2);
> break;
>
> case 'L':
> {
> int rel_addr = (((insn & 0xfff) ^ 0x800) - 0x800)
> * 2;
> ! sprintf (buf, ".%+-8d", rel_addr);
> ! sprintf (comment, "0x%x", pc + 2 + rel_addr);
> }
> break;
>
> case 'l':
> {
> int rel_addr = ((((insn >> 3) & 0x7f) ^ 0x40) -
> 0x40) * 2;
> ! sprintf (buf, ".%+-8d", rel_addr);
> ! sprintf (comment, "0x%x", pc + 2 + rel_addr);
> }
> break;
>
> --- 148,175 ----
> break;
>
> case 'h':
> ! *sym = 1;
> ! *sym_addr = ((((insn & 1) | ((insn & 0x1f0)
> >> 3)) << 16) | insn2) * 2;
> ! sprintf (buf, "0x");
> break;
>
> case 'L':
> {
> int rel_addr = (((insn & 0xfff) ^ 0x800) - 0x800)
> * 2;
> ! sprintf (comment, ".%+-8d", rel_addr);
> ! *sym = 1;
> ! *sym_addr = pc + 2 + rel_addr;
> ! sprintf (buf, "0x");
> }
> break;
>
> case 'l':
> {
> int rel_addr = ((((insn >> 3) & 0x7f) ^ 0x40) -
> 0x40) * 2;
> ! sprintf (comment, ".%+-8d", rel_addr);
> ! *sym = 1;
> ! *sym_addr = pc + 2 + rel_addr;
> ! sprintf (buf, "0x");
> }
> break;
>
> *************** print_insn_avr(addr, info)
> *** 265,270 ****
> --- 273,280 ----
> int cmd_len = 2;
> int ok = 0;
> char op1[20], op2[20], comment1[40],
> comment2[40];
> + int sym_op1 = 0, sym_op2 = 0;
> + bfd_vma sym_addr1, sym_addr2;
>
> if (!initialized)
> {
> *************** print_insn_avr(addr, info)
> *** 336,346 ****
> {
> int regs = REGISTER_P (*op);
>
> ! ok = avr_operand (insn, insn2, addr, *op, op1,
> comment1, 0);
>
> if (ok && *(++op) == ',')
> ok = avr_operand (insn, insn2, addr, *(++op),
> op2,
> ! *comment1 ? comment2 : comment1, regs);
> }
> }
>
> --- 346,356 ----
> {
> int regs = REGISTER_P (*op);
>
> ! ok = avr_operand (insn, insn2, addr, *op, op1,
> comment1, 0, &sym_op1, &sym_addr1);
>
> if (ok && *(++op) == ',')
> ok = avr_operand (insn, insn2, addr, *(++op),
> op2,
> ! *comment1 ? comment2 : comment1, regs,
> &sym_op2, &sym_addr2);
> }
> }
>
> *************** print_insn_avr(addr, info)
> *** 356,366 ****
> (*prin) (stream, "%s", ok ? opcode->name :
> ".word");
>
> if (*op1)
> ! (*prin) (stream, "\t%s", op1);
>
> if (*op2)
> (*prin) (stream, ", %s", op2);
>
> if (*comment1)
> (*prin) (stream, "\t; %s", comment1);
>
> --- 366,382 ----
> (*prin) (stream, "%s", ok ? opcode->name :
> ".word");
>
> if (*op1)
> ! (*prin) (stream, "\t%s", op1);
> !
> ! if (sym_op1)
> ! info->print_address_func(sym_addr1, info);
>
> if (*op2)
> (*prin) (stream, ", %s", op2);
>
> + if (sym_op2)
> + info->print_address_func(sym_addr2, info);
> +
> if (*comment1)
> (*prin) (stream, "\t; %s", comment1);
>
> > _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
=====
Vous manquez despace pour stocker vos mails ?
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/
Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour
dialoguer instantanément avec vos amis. A télécharger gratuitement sur
http://fr.messenger.yahoo.com