bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GAS branch bug (arm-elf)


From: Németh Márton
Subject: GAS branch bug (arm-elf)
Date: Mon, 17 Mar 2003 10:01:38 +0100 (MET)

Hi!

Short description of the problem:

Using binutils 2.13.2 (target arm-elf) the relative branch adresses will
be computed wrongly.


The problem in detail:

I have build binutils 2.13.2 with
./configure --target=arm-elf
and then do a make.

Here is the source code of the assembly code:
--- file: b.s -----------------------------------

@ backward branch tests

text_label:
        b       text_label
        b       text_label
        bal     text_label



@ forward branch tests
        b       text_label_end
        b       text_label_end
        b       text_label_end

text_label_end:


@ backward brach tests with conditions

label:
        b       label
        b       label
        beq     label
        bne     label
        bcs     label
        bcc     label
        bmi     label
        bpl     label
        bvs     label
        bvc     label
        bhi     label
        bls     label
        bge     label
        blt     label
        bgt     label
        ble     label
        bal     label

-------------------------------------------------

Let's compile this code:

-------------------------------------------------
# /home/nmarci/src/binutils-build/gas/as-new -v -a b.s -o b.o
GNU assembler version 2.13.2 (arm-elf) using BFD version 2.13.2
ARM GAS
b.s                      page 1


   1
   2                    @ backward branch tests
   3
   4                    text_label:
   5 0000 FEFFFFEA              b       text_label
   6 0004 FEFFFFEA              b       text_label
   7 0008 FEFFFFEA              bal     text_label
   8
   9
  10
  11                    @ forward branch tests
  12 000c 040000EA              b       text_label_end
  13 0010 040000EA              b       text_label_end
  14 0014 040000EA              b       text_label_end
  15
  16                    text_label_end:
  17
  18
  19                    @ backward brach tests with conditions
  20
  21                    label:
  22 0018 040000EA              b       label
  23 001c 040000EA              b       label
  24 0020 0400000A              beq     label
  25 0024 0400001A              bne     label
  26 0028 0400002A              bcs     label
  27 002c 0400003A              bcc     label
  28 0030 0400004A              bmi     label
  29 0034 0400005A              bpl     label
  30 0038 0400006A              bvs     label
  31 003c 0400007A              bvc     label
  32 0040 0400008A              bhi     label
  33 0044 0400009A              bls     label
  34 0048 040000AA              bge     label
  35 004c 040000BA              blt     label
  36 0050 040000CA              bgt     label
  37 0054 040000DA              ble     label
  38 0058 040000EA              bal     label
  39
ARM GAS  b.s                   page 2


DEFINED SYMBOLS
                 b.s:4      .text:00000000 text_label
                 b.s:16     .text:00000018 text_label_end
                 b.s:21     .text:00000018 label

NO UNDEFINED SYMBOLS
-------------------------------------------------

As you can see the lines 5, 6 and 7 there is the same binary code. This is
wrong, because the branch is relative, and with each instruction we will
farther and farther from the text_label.

Let's see what means this binary code:

-------------------------------------------------
# /home/nmarci/src/binutils-build/binutils/objcopy -O binary b.o b.bin
# /home/nmarci/src/binutils-build/binutils/objdump -b binary -m arm -D b.bin

b.bin:     file format binary

Disassembly of section .data:

00000000 <.data>:
   0:   eafffffe        b       0x0
   4:   eafffffe        b       0x4
   8:   eafffffe        b       0x8
   c:   ea000004        b       0x24
  10:   ea000004        b       0x28
  14:   ea000004        b       0x2c
  18:   ea000004        b       0x30
  1c:   ea000004        b       0x34
  20:   0a000004        beq     0x38
  24:   1a000004        bne     0x3c
  28:   2a000004        bcs     0x40
  2c:   3a000004        bcc     0x44
  30:   4a000004        bmi     0x48
  34:   5a000004        bpl     0x4c
  38:   6a000004        bvs     0x50
  3c:   7a000004        bvc     0x54
  40:   8a000004        bhi     0x58
  44:   9a000004        bls     0x5c
  48:   aa000004        bge     0x60
  4c:   ba000004        blt     0x64
  50:   ca000004        bgt     0x68
  54:   da000004        ble     0x6c
  58:   ea000004        b       0x70

-------------------------------------------------

The code at 0, 4, 8 is as an endless loop.
This code (0xeafffffe) is the example in ARM7 Data Sheet
(Doc No: ARM DDI 0020C, Issued: Dec 1994, ARM7vC.pdf,
available from http://www.arm.com/techdocs.nsf/html/ARM7Docs) page 22.
But the source b.s does not specify that kind of loops.

What is wrong here?

Thanks,

        Márton Németh

Student of Budapest University of Technology and Economics





reply via email to

[Prev in Thread] Current Thread [Next in Thread]