This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

adr r12,label fails silently for asarm/thumb when in thumb mode...


hi

when in .code 16 (thumb) mode, the assembler silently fails and
generates an unexpected instruction for "adr" under certain conditions.

here's a patch...

tom
Here's a proposed fix for a problem seen with the thumb assembler.
The thumb assembler failed silently assembling an "adr" instruction
if the register used was > R7...  It silently generated an unexpected
instruction...
======================================================================
2000-03-14 Thomas de Lellis <tdel@windriver.com>

        * config/tc-arm.c (do_t_adr): Flag "adr Rd,label"
        instruction operand bad if Rd > 7 when generating
        thumb instructions. Prevents for example,
        "adr r12,label" from silently failing and generating
        the wrong instruction.
        
======================================================================
*** tc-arm.c@@/main/5   Thu Jan 27 18:00:03 2000
--- tc-arm.c    Thu Mar 16 16:12:45 2000
*************** static void
*** 4868,4878 ****
  do_t_adr (str)
       char * str;
  {
    /* This is a pseudo-op of the form "adr rd, label" to be converted
       into a relative address of the form "add rd, pc, #label-.-4" */
    skip_whitespace (str);
  
!   if (reg_required_here (&str, 4) == FAIL  /* Store Rd in temporary location inside instruction.  */
        || skip_past_comma (&str) == FAIL
        || my_get_expression (&inst.reloc.exp, &str))
      {
--- 4868,4881 ----
  do_t_adr (str)
       char * str;
  {
+   int reg;
+ 
    /* This is a pseudo-op of the form "adr rd, label" to be converted
       into a relative address of the form "add rd, pc, #label-.-4" */
    skip_whitespace (str);
  
!   if ((reg = reg_required_here (&str, 4)) == FAIL  /* Store Rd in temporary location inside instruction.  */
!       || (reg > 7)  /* Thumb must be r0..r7 */
        || skip_past_comma (&str) == FAIL
        || my_get_expression (&inst.reloc.exp, &str))
      {
TESTCASE ==================================================================
> cat a.s
                .code   16
thing:  
                NOP
                ADR     r12,here
                ADR     r4,here
                NOP
                NOP
                NOP
here:
FAIL ======================================================================
> ./test
+ asarm -o a.o a.s 
+ objdumparm -d a.o 

a.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <thing>:
   0:   46c0            nop                     (mov r8,r8)
   2:   ac02            add     r4, sp, #8
   4:   a401            add     r4, pc, #4      (adr r4,c <here>)
   6:   46c0            nop                     (mov r8,r8)
   8:   46c0            nop                     (mov r8,r8)
   a:   46c0            nop                     (mov r8,r8)
PASS ======================================================================
> cat a.s
                .code   16
thing:  
                NOP
                ADR     r12,here
                ADR     r4,here
                NOP
                NOP
                NOP
here:
> ./test
+ asarm -o a.o a.s 
a.s: Assembler messages:
a.s:4: Error: Bad arguments to instruction

(and now a.s is edited...)

> cat a.s
                .code   16
thing:  
#               ADR     r12,here
                ADR     r4,here
                NOP
                NOP
                NOP
here:
> ./test
+ asarm -o a.o a.s 
+ objdumparm -d a.o 

a.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <thing>:
   0:   a401            add     r4, pc, #4      (adr r4,8 <here>)
   2:   46c0            nop                     (mov r8,r8)
   4:   46c0            nop                     (mov r8,r8)
   6:   46c0            nop                     (mov r8,r8)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]