This is the mail archive of the binutils@sources.redhat.com 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]

RFC: elfcode.h: eliminating assumption that e_shentsize == sizeof(Elf32_External_Shdr)


I would like to use the BFD code to do some postprocessing on an ELF file
for an Analog Devices DSP, and the files that I am working with all have
e_shentsize=44 in the ELF header. However,
sizeof(Elf32_External_Shdr)==40, and the rest of elfcode.h uses
sizeof(x_ehdr) (x_ehdr is of type Elf32_External_Shdr) to step through the
section header table.

I'm not convinced that I have a very authoritative copy of the ELF file
format description, as it is in a document called "Portable Formats
Specification, Version 1.1" from Intel. However, from the description of
the fields, extending the section header entries doesn't seem to be
discouraged, and it would appear that the fields in the ELF file (up to
the end of Elf32_External_Shdr) line up.

Would anyone have any objection to a modification of elfcode.h which uses
e_shentsize instead of sizeof(x_ehdr)? Since the value of e_shentsize is
compared to sizeof(x_ehdr) early on in the target matching process, I
assume that e_shentsize is either 40 or 64 (sizeof(Elf??_External_Shdr))
on all currently supported targets. My proposed change (not entirely coded
up yet) would add a target-specific #define to disable a warning/error if
e_shentsize isn't one of the expected values.

I haven't seen any indication that the extra four bytes are being used,
but then again, I am only looking at linked ELF files. At the very least,
I would like to be able to pass the executable through objcopy to
normalize the section headers.

-- 
Charles Lepple <clepple@ghz.cc>
http://www.ghz.cc/charles/



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