Problems converting elf32-sh to coff-sh
Ian Lance Taylor
ian@zembu.com
Fri Sep 10 16:57:00 GMT 1999
From: =?iso-8859-1?Q?Fran=E7ois_Costin?= <costin00@gel.ulaval.ca>
Date: Fri, 10 Sep 1999 17:44:19 -0400
I need for some reason to convert simple elf object files into coff files.
My compiler produces some R_SH_DIR32 relocations which are not supported by
the binutils for the conversion. I know you can't do it in the general
case, but I've managed somehow to remap the R_SH_DIR32 as a R_SH_IMM32
reloc. This part seems to work fine.
Only one exception... when an object file contains a reloc to a function
inside that same object file, the converter adds a weird negative offset to
the symbol name when I ask for an objdump -x.
I did find where the offset comes from there's a line in the coff-sh.c file
inside the CALC_ADDEND macro which goes like this:
cache_ptr->addend = -(ptr->section->vma + ptr->value);
I did try to simply change this to:
cache_ptr->addend = 0;
Now, after doing an objcopy -O coff-sh, when I do an objdump -x with the new
code, I do not see the offset. But when I do the objdump with an older
version of the code, it does see it. And it fact it stays there.
I'd just like to know where in the code I can once and for all delete that
offset. It is only for that specific application and I know that if I can
delete the offset, I'll have no problems anymore converting my object files.
You've already figured out how to delete that offset: change the
CALC_ADDEND macro.
I don't understand what else you are asking for. For coff-sh, the
addend computed by CALC_ADDEND and reported by objdump -x doesn't
reflect any value that actually appears in the object file. It is a
value computed solely to make the link work correctly.
Try generating a COFF file directly using the assembler, and see what
you get. You want to get the same results after the conversion from
ELF.
Ian
More information about the Binutils
mailing list