[Top][All Lists]

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

as: redefinition of relocatable items fails

From: Albert van der Horst
Subject: as: redefinition of relocatable items fails
Date: Wed, 24 Nov 2004 14:32:55 +0100
User-agent: Mutt/1.3.28i

Dear Sir,

This is a defect report against ``gnu as 2.15'' :

    .equ cannot handle redefinition for relocatable values.

Apparently .equ can handle redefinitions okay.
It has no problems with relocatable values, or with
a constant defined as the difference between relocatables.

This is shown in the following example :

GAS LISTING aap.s                       page 1

   2                    _START:
   3                            .equ AAP,    5
   4 0000 05000000             .long AAP      # Expect 5. Okay.
   5                            .equ AAP,    7
   6 0004 07000000             .long AAP      # Expect 7. Okay.
   7                            .equ NOOT,    .
   8 0008 08000000             .long NOOT      # Expect 8, but relocatable. 
   9                            .equ MIES,    .- _START
  10 000c 0C000000             .long MIES      # Expect 0x0c not relocatable. 
  11                            .equ AAP,    11
  12 0010 0B000000             .long AAP      # Expect 11. Okay.
GAS LISTING aap.s                      page 2

               aap.s:2      .text:00000000 _START
               aap.s:3      *ABS*:0000000b AAP
               aap.s:7      .text:00000008 NOOT
               aap.s:9      *ABS*:0000000c MIES


However, when redefining a name with a relocatable value,
the results are incorrect, or I believe so.

GAS LISTING jan.s                       page 1

   2                    _START:
   3 0000 8C8B8A89              .long 0x898a8b8c
   4                            .equ AAP,    .
   5 0004 0C000000             .long AAP      # Expect 4. What?
   6                            .equ AAP,    .
   7 0008 0C000000             .long AAP      # Expect 8. What?
   8                            .equ AAP,    .
   9 000c 0C000000             .long AAP      # Expect c.  last value 
apparently correct.
GAS LISTING jan.s                      page 2

               jan.s:2      .text:0000000000000000 _START
               jan.s:8      .text:000000000000000c AAP


For your convenience I added both assembler files in the

[The result is even more strange if you redefine AAP later
with a constant value. You are advised to look into that, as it
can give an indication of what is going on. I have this
example in the attachment noot.s.  This is of course slightly
naughty, so I did not want to present that as the defect.]

A note:
The ability to redefine a relocatable is a valuable feature for
something I'm doing: laying down linked lists.

    .equ link, .
    .long <d1>     ; Some data structure
    .long <d2>
    .long oldlink
    .equ oldlink, link

This structure can be repeated indefinitely, without the need
to define a "ganze Unmenge" of labels, and the textual manipulations
that go with them.

Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
        One man-hour to invent,
                One man-week to implement,
                        One lawyer-year to patent.
address@hidden http://home.hccnet.nl/a.w.m.van.der.horst

Attachment: noot.s
Description: Text document

Attachment: jan.s
Description: Text document

Attachment: aap.s
Description: Text document

reply via email to

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