This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: [PATCH] change the condition preventing symbol replacement in snapshot_symbol()


Hi Jan,

The question is whether an equate counts as a local symbol.

I'd really hope that Alan and or Nick could jump in here clarifying expected
behavior.

I didn't reply because I do not know the answer.


The documentation already states that equating one symbol with another is the same as using the .set directive. The .set directive says that the new symbol inherits the value and type of the original symbol. Thus one would expect that in:

  .global foo
  bar = foo

That bar behaves like a global symbol, not a local one.

We can change the documentation of course, and as H.J. has already pointed out, if foo is defined then the current behaviour is to treat bar as a local symbol.

To me though this seems wrong. As a programmer I would expect that equated symbols are the same. Ie that they can be treated as aliases of each other. I do not see the benefit of changing the nature of equated symbol.

I extended H.J.'s demonstration slightly:

  bar = foo
  baz = globule

        .globl foo
        .globl globule
  foo:
        jmp bar
        jmp foo
        jmp baz
        jmp globule

Which when assembled and dumped with objdump -dr gives:

00000000 <foo>:
   0:   eb fe                   jmp    0 <foo>
   2:   e9 fc ff ff ff          jmp    3 <foo+0x3>
                        3: R_386_PC32   foo
   7:   e9 fc ff ff ff          jmp    8 <foo+0x8>
                        8: R_386_PC32   globule
   c:   e9 fc ff ff ff          jmp    d <foo+0xd>
                        d: R_386_PC32   globule

The first jmp just seems plain wrong to me. I would expect it to have a relocation against the foo symbol just like all of the others.

So, in my opinion: "no, equating a symbol does not make it local".

Cheers
  Nick


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