extending elf32-i386 BFD backend
Graeme Peterson
gp@qnx.com
Fri Mar 22 09:42:00 GMT 2002
Hi, all.
I'm working on the i386-pc-nto-qnx support for binutils.
QNX now has Copyright Assignment, and the ntox86 support
is ready for submission, with one exception.
Throughout elf.c, there are checks to see if a segment
is loadable (or not):
if (segment->type == PT_LOAD)
or
if (phdr->p_type == PT_LOAD)
QNX6 has 2 other loadable ptypes defined in our sys/elf.h
PT_COMPRESS = 0x4000
PT_SEGREL = 0x4001
Nick Clifton has been very helpful (Thanks Nick!), and suggests
I add a new BFD backend function, and then have a macro in
bfd/elf.c :
#define IS_LOADABLE_SEGMENT(abfd, seg, bed) \
(bed->is_loadable_segment \
? bed->is_loadable_segment (abfd, seg) \
: (seg)->type == PT_LOAD)
The only way (I think) I know to do that is to copy elf32-i386.c,
rename it to something like elfqnx-i386.c, add the BFD backend
extension, and put the support in config.bfd, Makefile.in, targets.c...
(I have never added a new BFD backend, so the above may not be
right).
I don't want to copy elf32-i386.c just to add one small function
that boils down to:
(type == PT_LOAD || type == PT_COMPRESS || type == PT_SEGREL)
Other than the above, we use the stock i386 elf code, and I would
like to keep using the latest cut of that, rather than the cut I
made a copy of.
Is there another acceptable way of setting this up? Somewhere that
I could:
#define HAS_IS_LOADABLE_PTYPE 1
#define IS_LOADABLE_PTYPE(type) \
(type == PT_LOAD || type == PT_COMPRESS || type == PT_SEGREL)
Then in elf.c I could:
#define IS_LOADABLE_P_TYPE(type) Â \
(HAS_IS_LOADABLE_PTYPE \
? IS_LOADABLE_PTYPE(type) \
: (type == PT_LOAD)
Then I can replace:
if (segment->type == PT_LOAD)
if (phdr->p_type == PT_LOAD)
with
if (IS_LOADABLE_P_TYPE(segment->type)
if (IS_LOADABLE_P_TYPE(phdr->p_type)
Any and all suggestions/comments appreciated.
Cheers,
Graeme Peterson (GP)
QNX Tools Group.
More information about the Binutils
mailing list