GAS overwrittes important bits when reading from symbol table
DJ Delorie
dj@redhat.com
Tue Oct 18 21:21:00 GMT 2005
Well, it depends on how your proprietary assembler was written. Since
you don't say, we can't help you much, but here is some general help.
When parsing opcodes, gas builds a list of "fragments" that are
partially filled in on the first pass (and may be varying in size if
the size of the opcode is not known on the first pass). Additionally,
a set of fixups are created that connect the operand fields of each
opcode to the addresses they refer to. Each fixup has a fixup type,
which tells gas and ld *how* to put the value into that field.
If the symbol is defined locally, gas can usually put the value in.
Look for a function called md_convert_frag in gas/config/tc-*.c
If the symbol isn't local, gas emits a relocation which is filled in
by the linker. Look for a function like *_relocate_section or
*_final_link_relocate in your target-specific bfd/*.c
The relocation for your jump would have to be specific to a field that
has three bits that must be preserved; you can't use a generic 26 bit
relocation. Perhaps something like R_MYCPU_JUMP_26_3. Both gas and
bfd would use this relocation to mean "leave the lower three bits
alone" so the code would have to know to mask those bits properly.
More information about the Binutils
mailing list