public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
@ 2003-07-10 15:38 Vincent Rubiolo
  2003-07-11 14:35 ` Nick Clifton
       [not found] ` <H0000cba18680191.1057939164.eux100.sgp.st.com@MHS>
  0 siblings, 2 replies; 10+ messages in thread
From: Vincent Rubiolo @ 2003-07-10 15:38 UTC (permalink / raw)
  To: binutils

Hello,

This may be very stupid but I am unable to use both flags -Mreg-names-raw and 
-Mforce-thumb at the same time (arm-elf-objdump)
I tried :
-Mreg-names-raw -Mforce-thumb
--disassemble-options=reg-names-raw --disassemble-options=force-thumb
--disassemble-options=reg-names-raw,force-thumb
I also switched the order of the parameters. No help.

I understand that almost all others flags are exclusive hence a possible reason 
of this behavior. I nevertheless think these two should be usable at the same time.

Am I doing something wrong? I am really puzzled...

Regards,

Vincent

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
  2003-07-10 15:38 [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw) Vincent Rubiolo
@ 2003-07-11 14:35 ` Nick Clifton
       [not found] ` <H0000cba18680191.1057939164.eux100.sgp.st.com@MHS>
  1 sibling, 0 replies; 10+ messages in thread
From: Nick Clifton @ 2003-07-11 14:35 UTC (permalink / raw)
  To: Vincent Rubiolo; +Cc: binutils

Hi Vincent,

> This may be very stupid but I am unable to use both flags
> -Mreg-names-raw and -Mforce-thumb at the same time (arm-elf-objdump)

Which version of binutils are you using ?

It appears to work for me (using the current CVS sources and the 2.14
release):

  % objdump -d mov.o
 
     0:   e1a0e00f        mov     lr, pc

  % objdump -d -Mreg-names-raw nop.o
 
     0:   e1a0e00f        mov     r14, r15

   % objdump -d -Mreg-names-raw -Mforce-thumb nop.o
 
     0:   e00f            b       22 <fred+0x22>
     2:   e1a0            b       346 <fred+0x346>
 
Cheers
        Nick

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
       [not found] ` <H0000cba18680191.1057939164.eux100.sgp.st.com@MHS>
@ 2003-07-14 14:48   ` Vincent Rubiolo
  2003-07-17 14:44     ` Nick Clifton
       [not found]     ` <H0000cba186df243.1058453251.eux100.sgp.st.com@MHS>
  0 siblings, 2 replies; 10+ messages in thread
From: Vincent Rubiolo @ 2003-07-14 14:48 UTC (permalink / raw)
  To: binutils; +Cc: nickc

Hello,

Sorry for the delay.
I am using binutils 2.14 and also a snapshot from the 19th of June.

The problem arises when I try to inspect THUMB code generated by ADS 
(interworking enabled). I have to use -Mforce-thumb, otherwise everything is 
seen as ARM code.
Here are the outputs (from a C file compiled as THUMB):


% arm-elf-objdump -d ADS_file -Mforce-thumb
  	1002444:       b510            push    {r4, lr}

% arm-elf-objdump -d ADS_file -Mforce-thumb -Mreg-names-raw
	1002444:       2400b510        strcs   r11, [r0], -#1296

The first one is correct.
Pb then, as it seems that the -Mreg-names-raw turned off the -Mforce-thumb 
option on the second attempt.


Also, on ARM code, it works just as you stated:
% arm-elf-objdump -d ADS_file
	1000150:       e1a0f00c        mov     pc, ip

% arm-elf-objdump -d ADS_file -Mreg-names-raw
	1000150:       e1a0f00c        mov     r15, r12

% arm-elf-objdump -d ADS_file -Mreg-names-raw -Mforce-thumb
	1000150:       e1a0f00c        blx     100c494 <$b+0x36>


Hope that clarify the situation. Thing is I am operating the opposite way 
(looking at THUMB code).

Regards,

Vincent


nickc@redhat.com wrote:

> Hi Vincent,
> 
> 
>>This may be very stupid but I am unable to use both flags
>>-Mreg-names-raw and -Mforce-thumb at the same time (arm-elf-objdump)
> 
> 
> Which version of binutils are you using ?
> 
> It appears to work for me (using the current CVS sources and the 2.14
> release):
> 
>   % objdump -d mov.o
>  
>      0:   e1a0e00f        mov     lr, pc
> 
>   % objdump -d -Mreg-names-raw nop.o
>  
>      0:   e1a0e00f        mov     r14, r15
> 
>    % objdump -d -Mreg-names-raw -Mforce-thumb nop.o
>  
>      0:   e00f            b       22 <fred+0x22>
>      2:   e1a0            b       346 <fred+0x346>
>  
> Cheers
>         Nick
> 

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
  2003-07-14 14:48   ` Vincent Rubiolo
@ 2003-07-17 14:44     ` Nick Clifton
       [not found]     ` <H0000cba186df243.1058453251.eux100.sgp.st.com@MHS>
  1 sibling, 0 replies; 10+ messages in thread
From: Nick Clifton @ 2003-07-17 14:44 UTC (permalink / raw)
  To: Vincent Rubiolo; +Cc: binutils

Hi Vincent,

> The problem arises when I try to inspect THUMB code generated by ADS
> (interworking enabled). I have to use -Mforce-thumb, otherwise
> everything is seen as ARM code.

Hmm - it is probably a case of ADS and GAS using different methods to
diostinguish between ARM and THUMB code in their object files.  Please
could you send me a *small* ADS object file which demonstrates this
problem, so that I can try to find a fix ?

Cheers
        Nick
        

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
       [not found]     ` <H0000cba186df243.1058453251.eux100.sgp.st.com@MHS>
@ 2003-07-17 15:31       ` Vincent Rubiolo
  2003-07-17 17:02         ` Nick Clifton
  0 siblings, 1 reply; 10+ messages in thread
From: Vincent Rubiolo @ 2003-07-17 15:31 UTC (permalink / raw)
  To: nickc; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]

Hello Nick,

Thanks for your reply.

Investigating a little more, this seems to happen even with ARM-only/THUMB_only 
code: the disassembler turns off -Mforce-thumb option when used with 
-Mreg-names-raw for an ADS object file, either ARM or THUMB code.

You will find enclosed four files:
1. Hello.c is the source of an Hello World program (in case you need it)
2. Hello-THUMB.o is output of tcc, the ADS THUMB C compiler
3. Hello-ARM.o is the output of armcc, the ADS ARM C compiler (so you may 
compare if needed)
4. The different commands issued to spot the problem

Note: To decrease the size of the object files, I disabled linking.
Let me tell you if there are other things you may find useful.

Thank you very much for your consideration.

Best regards,

Vincent

PS: I will only be back on Tuesday so I will not be able to reply before


nickc@redhat.com wrote:

[snip]
> Hmm - it is probably a case of ADS and GAS using different methods to
> distinguish between ARM and THUMB code in their object files.  Please
> could you send me a *small* ADS object file which demonstrates this
> problem, so that I can try to find a fix ?
> 
> Cheers
>         Nick
>         
> 

[-- Attachment #2: Hello.c --]
[-- Type: text/plain, Size: 74 bytes --]

#include <stdio.h>

int main() {
  printf("Hello World\n");
  return 0;
}

[-- Attachment #3: Commands --]
[-- Type: text/plain, Size: 1736 bytes --]

$ arm-elf-objdump -d Hello.o

Hello.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <main>:
   0:   a002b580        andge   fp, r2, r0, lsl #11

00000004 <$b>:
   4:   fffef7ff        swinv   0x00fef7ff
   8:   bd802000        stclt   0, cr2, [r0]

0000000c <$d>:
   c:   6c6c6548        cfstr64vs       mvdx6, [ip], -#288
  10:   6f57206f        swivs   0x0057206f
  14:   0a646c72        beq     191b1e4 <$d+0x191b1d8>
  18:   00000000        andeq   r0, r0, r0



$ arm-elf-objdump -d -Mforce-thumb Hello.o 
Hello.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <main>:
   0:   b580            push    {r7, lr}
   2:   a002            add     r0, pc, #8      (adr r0,c <$d>)

00000004 <$b>:
   4:   fffef7ff        bl      0 <main>
   8:   2000            mov     r0, #0
   a:   bd80            pop     {r7, pc}

0000000c <$d>:
   c:   6548            str     r0, [r1, #84]
   e:   6c6c            ldr     r4, [r5, #68]
  10:   206f            mov     r0, #111
  12:   6f57            ldr     r7, [r2, #116]
  14:   6c72            ldr     r2, [r6, #68]
  16:   0a64            lsr     r4, r4, #9
  18:   0000            lsl     r0, r0, #0
        ...


$ arm-elf-objdump -d -Mforce-thumb -Mreg-names-raw Hello.o

Hello.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <main>:
   0:   a002b580        andge   r11, r2, r0, lsl #11

00000004 <$b>:
   4:   fffef7ff        swinv   0x00fef7ff
   8:   bd802000        stclt   0, cr2, [r0]

0000000c <$d>:
   c:   6c6c6548        cfstr64vs       mvdx6, [r12], -#288
  10:   6f57206f        swivs   0x0057206f
  14:   0a646c72        beq     191b1e4 <$d+0x191b1d8>
  18:   00000000        andeq   r0, r0, r0

[-- Attachment #4: Hello-ARM.o --]
[-- Type: application/octet-stream, Size: 1096 bytes --]

[-- Attachment #5: Hello-THUMB.o --]
[-- Type: application/octet-stream, Size: 1104 bytes --]

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
  2003-07-17 15:31       ` Vincent Rubiolo
@ 2003-07-17 17:02         ` Nick Clifton
  2003-07-17 18:39           ` Daniel Jacobowitz
  2003-07-18  8:05           ` [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw) Andreas Schwab
  0 siblings, 2 replies; 10+ messages in thread
From: Nick Clifton @ 2003-07-17 17:02 UTC (permalink / raw)
  To: Vincent Rubiolo; +Cc: binutils

Hi Vincent,

> Investigating a little more, this seems to happen even with
> ARM-only/THUMB_only code: the disassembler turns off -Mforce-thumb
> option when used with -Mreg-names-raw for an ADS object file, either
> ARM or THUMB code.

Thanks for the files.  I have now reproduced the problem - and you are
right.  Objdump does ignore all but the last -M switch on the command
line.  This is a consequence of the way the program is designed (or
rather evolved).

Fortunately however there is a workaround: combine the switches into a
single space separated list.  ie:

  -M"force-thumb reg-names-raw"

The attached patch will make objdump generate suitable warning
messages if multiple -M switches are used and it updates the
documentation to describe this "feature".

Cheers
        Nick

2003-07-17  Nick Clifton  <nickc@redhat.com>

	* objdump.c (main): Issue a warning message if multiple -M
	switches are used.
	
	* doc/binutils.texi (objdump): Update documentation about -M
	option.
	
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.67
diff -c -3 -p -r1.67 objdump.c
*** binutils/objdump.c	25 Jun 2003 06:40:25 -0000	1.67
--- binutils/objdump.c	17 Jul 2003 16:58:47 -0000
*************** main (argc, argv)
*** 2660,2665 ****
--- 2660,2671 ----
  	  machine = optarg;
  	  break;
  	case 'M':
+ 	  if (disassembler_options)
+ 	    {
+ 	      non_fatal ("multiple separate -M options are not supported.");
+ 	      non_fatal ("please combine them into a single, space separated option.");
+ 	      non_fatal ("ignoring option '-M%s'", disassembler_options);
+ 	    }
  	  disassembler_options = optarg;
  	  break;
  	case 'j':

Index: binutils/doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.42
diff -c -3 -p -r1.42 binutils.texi
*** binutils/doc/binutils.texi	26 Jun 2003 08:14:10 -0000	1.42
--- binutils/doc/binutils.texi	17 Jul 2003 16:58:51 -0000
*************** architectures with the @option{-i} optio
*** 1625,1631 ****
  @item -M @var{options}
  @itemx --disassembler-options=@var{options}
  Pass target specific information to the disassembler.  Only supported on
! some targets.
  
  If the target is an ARM architecture then this switch can be used to
  select which register name set is used during disassembler.  Specifying
--- 1625,1639 ----
  @item -M @var{options}
  @itemx --disassembler-options=@var{options}
  Pass target specific information to the disassembler.  Only supported on
! some targets.  Note only a single instance of the option on the
! command line is supported.  If the option occurs more than once, the
! earlier versions will be ignored.  If it is necessary to specify more
! than one disassembler option then they should be placed together into
! a space separated list.  ie:
! 
! @smallexample
!   -M"first-disassembler-option second-disassembler-option"
! @end smallexample
  
  If the target is an ARM architecture then this switch can be used to
  select which register name set is used during disassembler.  Specifying
        

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
  2003-07-17 17:02         ` Nick Clifton
@ 2003-07-17 18:39           ` Daniel Jacobowitz
  2003-07-18 11:34             ` Nick Clifton
       [not found]             ` <H0000cba187217e5.1058853947.eux100.sgp.st.com@MHS>
  2003-07-18  8:05           ` [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw) Andreas Schwab
  1 sibling, 2 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2003-07-17 18:39 UTC (permalink / raw)
  To: binutils

On Thu, Jul 17, 2003 at 05:48:45PM +0100, Nick Clifton wrote:
>   	case 'M':
> + 	  if (disassembler_options)
> + 	    {
> + 	      non_fatal ("multiple separate -M options are not supported.");
> + 	      non_fatal ("please combine them into a single, space separated option.");
> + 	      non_fatal ("ignoring option '-M%s'", disassembler_options);
> + 	    }
>   	  disassembler_options = optarg;
>   	  break;
>   	case 'j':
> 

Is there any reason not to do:
  disassembler_options = concat (disassembler_options, " ", optarg, NULL);
instead?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
  2003-07-17 17:02         ` Nick Clifton
  2003-07-17 18:39           ` Daniel Jacobowitz
@ 2003-07-18  8:05           ` Andreas Schwab
  1 sibling, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2003-07-18  8:05 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Vincent Rubiolo, binutils

Nick Clifton <nickc@redhat.com> writes:

|> Fortunately however there is a workaround: combine the switches into a
|> single space separated list.  ie:
|> 
|>   -M"force-thumb reg-names-raw"

IMHO combining them with commas would be nicer.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw)
  2003-07-17 18:39           ` Daniel Jacobowitz
@ 2003-07-18 11:34             ` Nick Clifton
       [not found]             ` <H0000cba187217e5.1058853947.eux100.sgp.st.com@MHS>
  1 sibling, 0 replies; 10+ messages in thread
From: Nick Clifton @ 2003-07-18 11:34 UTC (permalink / raw)
  To: binutils

Hi Guys,

  I am applying this patch which should fix the parsing of the -M
  switch properly.

  It allows multiple -M switches on the command line, and it documents
  that a single -M switch can contain comma separated target specific
  options.  It also updates the arm disassembler to accept these comma
  separated options.

Cheers
        Nick

binutils/ChangeLog
2003-07-18  Nick Clifton  <nickc@redhat.com>

	* objdump.c (main) :Accept multiple -M switch.
        * doc/binutils.texi: Document that multiple -M switches are
        accepted and that a single -M switch can contain comma
        separated options.

opcodes/ChangeLog
2003-07-18  Nick Clifton  <nickc@redhat.com>

	* arm-dis.c (parse_arm_disassembler_option): Do not expect
	option string to be NUL terminated.
        (parse_disassembler_options): Allow options to be space or
	comma separated.  

Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.68
diff -c -3 -p -r1.68 objdump.c
*** binutils/objdump.c	17 Jul 2003 17:02:46 -0000	1.68
--- binutils/objdump.c	18 Jul 2003 11:17:36 -0000
*************** main (argc, argv)
*** 2661,2672 ****
  	  break;
  	case 'M':
  	  if (disassembler_options)
! 	    {
! 	      non_fatal ("multiple separate -M options are not supported.");
! 	      non_fatal ("please combine them into a single, space separated option.");
! 	      non_fatal ("ignoring option '-M%s'", disassembler_options);
! 	    }
! 	  disassembler_options = optarg;
  	  break;
  	case 'j':
  	  if (only == NULL)
--- 2661,2670 ----
  	  break;
  	case 'M':
  	  if (disassembler_options)
! 	    /* Ignore potential memory leak for now.  */
! 	    disassembler_options = concat (disassembler_options, ",", optarg, NULL);
! 	  else
! 	    disassembler_options = optarg;
  	  break;
  	case 'j':
  	  if (only == NULL)
Index: binutils/doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.43
diff -c -3 -p -r1.43 binutils.texi
*** binutils/doc/binutils.texi	17 Jul 2003 17:02:46 -0000	1.43
--- binutils/doc/binutils.texi	18 Jul 2003 11:17:40 -0000
*************** architectures with the @option{-i} optio
*** 1625,1639 ****
  @item -M @var{options}
  @itemx --disassembler-options=@var{options}
  Pass target specific information to the disassembler.  Only supported on
! some targets.  Note only a single instance of the option on the
! command line is supported.  If the option occurs more than once, the
! earlier versions will be ignored.  If it is necessary to specify more
! than one disassembler option then they should be placed together into
! a space separated list.  ie:
! 
! @smallexample
!   -M"first-disassembler-option second-disassembler-option"
! @end smallexample
  
  If the target is an ARM architecture then this switch can be used to
  select which register name set is used during disassembler.  Specifying
--- 1625,1633 ----
  @item -M @var{options}
  @itemx --disassembler-options=@var{options}
  Pass target specific information to the disassembler.  Only supported on
! some targets.  If it is necessary to specify more than one
! disassembler option then multiple @option{-M} options can be used or
! can be placed together into a comma separated list.
  
  If the target is an ARM architecture then this switch can be used to
  select which register name set is used during disassembler.  Specifying
Index: opcodes/arm-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/arm-dis.c,v
retrieving revision 1.32
diff -c -3 -p -r1.32 arm-dis.c
*** opcodes/arm-dis.c	1 Apr 2003 13:08:06 -0000	1.32
--- opcodes/arm-dis.c	18 Jul 2003 11:17:41 -0000
***************
*** 27,32 ****
--- 27,33 ----
  #include "coff/internal.h"
  #include "libcoff.h"
  #include "opintl.h"
+ #include "safe-ctype.h"
  
  /* FIXME: This shouldn't be done here.  */
  #include "elf-bfd.h"
*************** parse_arm_disassembler_option (option)
*** 1152,1202 ****
        option += 10;
  
        for (i = NUM_ARM_REGNAMES; i--;)
! 	if (streq (option, regnames[i].name))
  	  {
  	    regname_selected = i;
  	    break;
  	  }
  
        if (i < 0)
  	fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
      }
!   else if (streq (option, "force-thumb"))
      force_thumb = 1;
!   else if (streq (option, "no-force-thumb"))
      force_thumb = 0;
    else
      fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
  
    return;
  }
  
! /* Parse the string of disassembler options, spliting it at whitespaces.  */
  
  static void
  parse_disassembler_options (options)
       char * options;
  {
-   char * space;
- 
    if (options == NULL)
      return;
  
!   do
      {
!       space = strchr (options, ' ');
  
!       if (space)
! 	{
! 	  * space = '\0';
! 	  parse_arm_disassembler_option (options);
! 	  * space = ' ';
! 	  options = space + 1;
! 	}
!       else
! 	parse_arm_disassembler_option (options);
      }
-   while (space);
  }
  
  /* NOTE: There are no checks in these routines that
--- 1153,1200 ----
        option += 10;
  
        for (i = NUM_ARM_REGNAMES; i--;)
! 	if (strneq (option, regnames[i].name, strlen (regnames[i].name)))
  	  {
  	    regname_selected = i;
  	    break;
  	  }
  
        if (i < 0)
+ 	/* XXX - should break 'option' at following delimiter.  */
  	fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
      }
!   else if (strneq (option, "force-thumb", 11))
      force_thumb = 1;
!   else if (strneq (option, "no-force-thumb", 14))
      force_thumb = 0;
    else
+     /* XXX - should break 'option' at following delimiter.  */
      fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
  
    return;
  }
  
! /* Parse the string of disassembler options, spliting it at whitespaces
!    or commas.  (Whitespace separators supported for backwards compatibility).  */
  
  static void
  parse_disassembler_options (options)
       char * options;
  {
    if (options == NULL)
      return;
  
!   while (*options)
      {
!       parse_arm_disassembler_option (options);
  
!       /* Skip forward to next seperator.  */
!       while ((*options) && (! ISSPACE (*options)) && (*options != ','))
! 	++ options;
!       /* Skip forward past seperators.  */
!       while (ISSPACE (*options) || (*options == ','))
! 	++ options;      
      }
  }
  
  /* NOTE: There are no checks in these routines that
        

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

* Re: [arnm-elf-objdump] Can't use two -M flags for disassembler [SOLVED]
       [not found]             ` <H0000cba187217e5.1058853947.eux100.sgp.st.com@MHS>
@ 2003-07-23  6:39               ` Vincent Rubiolo
  0 siblings, 0 replies; 10+ messages in thread
From: Vincent Rubiolo @ 2003-07-23  6:39 UTC (permalink / raw)
  To: nickc; +Cc: binutils

Hello !

Thanks to you all for you time and consideration concerning this problem. I am 
hereby applying the patch and building the new binutils.

Thank you very much Nick!

Regards,

Vincent

nickc@redhat.com wrote:

> Hi Guys,
> 
>   I am applying this patch which should fix the parsing of the -M
>   switch properly.
> 
>   It allows multiple -M switches on the command line, and it documents
>   that a single -M switch can contain comma separated target specific
>   options.  It also updates the arm disassembler to accept these comma
>   separated options.
> 
> Cheers
>         Nick
> 
> binutils/ChangeLog
> 2003-07-18  Nick Clifton  <nickc@redhat.com>
> 
> 	* objdump.c (main) :Accept multiple -M switch.
>         * doc/binutils.texi: Document that multiple -M switches are
>         accepted and that a single -M switch can contain comma
>         separated options.
> 
> opcodes/ChangeLog
> 2003-07-18  Nick Clifton  <nickc@redhat.com>
> 
> 	* arm-dis.c (parse_arm_disassembler_option): Do not expect
> 	option string to be NUL terminated.
>         (parse_disassembler_options): Allow options to be space or
> 	comma separated.  
> 
> Index: binutils/objdump.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/objdump.c,v
> retrieving revision 1.68
> diff -c -3 -p -r1.68 objdump.c
> *** binutils/objdump.c	17 Jul 2003 17:02:46 -0000	1.68
> --- binutils/objdump.c	18 Jul 2003 11:17:36 -0000
> *************** main (argc, argv)
> *** 2661,2672 ****
>   	  break;
>   	case 'M':
>   	  if (disassembler_options)
> ! 	    {
> ! 	      non_fatal ("multiple separate -M options are not supported.");
> ! 	      non_fatal ("please combine them into a single, space separated option.");
> ! 	      non_fatal ("ignoring option '-M%s'", disassembler_options);
> ! 	    }
> ! 	  disassembler_options = optarg;
>   	  break;
>   	case 'j':
>   	  if (only == NULL)
> --- 2661,2670 ----
>   	  break;
>   	case 'M':
>   	  if (disassembler_options)
> ! 	    /* Ignore potential memory leak for now.  */
> ! 	    disassembler_options = concat (disassembler_options, ",", optarg, NULL);
> ! 	  else
> ! 	    disassembler_options = optarg;
>   	  break;
>   	case 'j':
>   	  if (only == NULL)
> Index: binutils/doc/binutils.texi
> ===================================================================
> RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
> retrieving revision 1.43
> diff -c -3 -p -r1.43 binutils.texi
> *** binutils/doc/binutils.texi	17 Jul 2003 17:02:46 -0000	1.43
> --- binutils/doc/binutils.texi	18 Jul 2003 11:17:40 -0000
> *************** architectures with the @option{-i} optio
> *** 1625,1639 ****
>   @item -M @var{options}
>   @itemx --disassembler-options=@var{options}
>   Pass target specific information to the disassembler.  Only supported on
> ! some targets.  Note only a single instance of the option on the
> ! command line is supported.  If the option occurs more than once, the
> ! earlier versions will be ignored.  If it is necessary to specify more
> ! than one disassembler option then they should be placed together into
> ! a space separated list.  ie:
> ! 
> ! @smallexample
> !   -M"first-disassembler-option second-disassembler-option"
> ! @end smallexample
>   
>   If the target is an ARM architecture then this switch can be used to
>   select which register name set is used during disassembler.  Specifying
> --- 1625,1633 ----
>   @item -M @var{options}
>   @itemx --disassembler-options=@var{options}
>   Pass target specific information to the disassembler.  Only supported on
> ! some targets.  If it is necessary to specify more than one
> ! disassembler option then multiple @option{-M} options can be used or
> ! can be placed together into a comma separated list.
>   
>   If the target is an ARM architecture then this switch can be used to
>   select which register name set is used during disassembler.  Specifying
> Index: opcodes/arm-dis.c
> ===================================================================
> RCS file: /cvs/src/src/opcodes/arm-dis.c,v
> retrieving revision 1.32
> diff -c -3 -p -r1.32 arm-dis.c
> *** opcodes/arm-dis.c	1 Apr 2003 13:08:06 -0000	1.32
> --- opcodes/arm-dis.c	18 Jul 2003 11:17:41 -0000
> ***************
> *** 27,32 ****
> --- 27,33 ----
>   #include "coff/internal.h"
>   #include "libcoff.h"
>   #include "opintl.h"
> + #include "safe-ctype.h"
>   
>   /* FIXME: This shouldn't be done here.  */
>   #include "elf-bfd.h"
> *************** parse_arm_disassembler_option (option)
> *** 1152,1202 ****
>         option += 10;
>   
>         for (i = NUM_ARM_REGNAMES; i--;)
> ! 	if (streq (option, regnames[i].name))
>   	  {
>   	    regname_selected = i;
>   	    break;
>   	  }
>   
>         if (i < 0)
>   	fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
>       }
> !   else if (streq (option, "force-thumb"))
>       force_thumb = 1;
> !   else if (streq (option, "no-force-thumb"))
>       force_thumb = 0;
>     else
>       fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
>   
>     return;
>   }
>   
> ! /* Parse the string of disassembler options, spliting it at whitespaces.  */
>   
>   static void
>   parse_disassembler_options (options)
>        char * options;
>   {
> -   char * space;
> - 
>     if (options == NULL)
>       return;
>   
> !   do
>       {
> !       space = strchr (options, ' ');
>   
> !       if (space)
> ! 	{
> ! 	  * space = '\0';
> ! 	  parse_arm_disassembler_option (options);
> ! 	  * space = ' ';
> ! 	  options = space + 1;
> ! 	}
> !       else
> ! 	parse_arm_disassembler_option (options);
>       }
> -   while (space);
>   }
>   
>   /* NOTE: There are no checks in these routines that
> --- 1153,1200 ----
>         option += 10;
>   
>         for (i = NUM_ARM_REGNAMES; i--;)
> ! 	if (strneq (option, regnames[i].name, strlen (regnames[i].name)))
>   	  {
>   	    regname_selected = i;
>   	    break;
>   	  }
>   
>         if (i < 0)
> + 	/* XXX - should break 'option' at following delimiter.  */
>   	fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
>       }
> !   else if (strneq (option, "force-thumb", 11))
>       force_thumb = 1;
> !   else if (strneq (option, "no-force-thumb", 14))
>       force_thumb = 0;
>     else
> +     /* XXX - should break 'option' at following delimiter.  */
>       fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
>   
>     return;
>   }
>   
> ! /* Parse the string of disassembler options, spliting it at whitespaces
> !    or commas.  (Whitespace separators supported for backwards compatibility).  */
>   
>   static void
>   parse_disassembler_options (options)
>        char * options;
>   {
>     if (options == NULL)
>       return;
>   
> !   while (*options)
>       {
> !       parse_arm_disassembler_option (options);
>   
> !       /* Skip forward to next seperator.  */
> !       while ((*options) && (! ISSPACE (*options)) && (*options != ','))
> ! 	++ options;
> !       /* Skip forward past seperators.  */
> !       while (ISSPACE (*options) || (*options == ','))
> ! 	++ options;      
>       }
>   }
>   
>   /* NOTE: There are no checks in these routines that
>         
> 

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

end of thread, other threads:[~2003-07-23  6:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-10 15:38 [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw) Vincent Rubiolo
2003-07-11 14:35 ` Nick Clifton
     [not found] ` <H0000cba18680191.1057939164.eux100.sgp.st.com@MHS>
2003-07-14 14:48   ` Vincent Rubiolo
2003-07-17 14:44     ` Nick Clifton
     [not found]     ` <H0000cba186df243.1058453251.eux100.sgp.st.com@MHS>
2003-07-17 15:31       ` Vincent Rubiolo
2003-07-17 17:02         ` Nick Clifton
2003-07-17 18:39           ` Daniel Jacobowitz
2003-07-18 11:34             ` Nick Clifton
     [not found]             ` <H0000cba187217e5.1058853947.eux100.sgp.st.com@MHS>
2003-07-23  6:39               ` [arnm-elf-objdump] Can't use two -M flags for disassembler [SOLVED] Vincent Rubiolo
2003-07-18  8:05           ` [arnm-elf-objdump] Can't use two -M flags for disassembler (-Mforce-thumb and -Mreg-names-raw) Andreas Schwab

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