mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-02-26 17:03:30 +00:00
pdp10-elf36: change Ehdr e_ident{1,2,3,4} to e_wident[4] to make it eaiser to process, define EI_NIDENT, define ELF36_EHDR_SIZEOF or avoid host-level sizeof mishaps
This commit is contained in:
@@ -19,6 +19,8 @@ typedef pdp10_uint36_t Elf36_Word;
|
||||
|
||||
/* ELF Header */
|
||||
|
||||
#define EI_NIDENT 16
|
||||
|
||||
typedef struct {
|
||||
/* In the standard 32 and 64 bit ELF specifications the ELF header starts
|
||||
* with a 16-octet e_ident[] array, of which the first 9 octets are defined,
|
||||
@@ -26,10 +28,7 @@ typedef struct {
|
||||
* e_ident with Elf36, we pack the first 9 octets in two 36-bit words, and
|
||||
* add two words of padding, making e_ident 16 bits larger in Elf36.
|
||||
*/
|
||||
Elf36_Word e_ident1; /* e_ident[] indices 0 to 4.5 */
|
||||
Elf36_Word e_ident2; /* e_ident[] indices 4.5 to 8 */
|
||||
Elf36_Word e_ident3; /* padding zeros */
|
||||
Elf36_Word e_ident4; /* padding zeros */
|
||||
Elf36_Word e_wident[4]; /* e_ident[] indices 0 to 4.5 */
|
||||
Elf36_Half e_type; /* Identifies object file type */
|
||||
Elf36_Half e_machine; /* Specifies required architecture */
|
||||
Elf36_Word e_version; /* Identifies object file version */
|
||||
@@ -45,6 +44,8 @@ typedef struct {
|
||||
Elf36_Half e_shstrndx; /* Section header string table index */
|
||||
} Elf36_Ehdr;
|
||||
|
||||
#define ELF36_EHDR_SIZEOF (8 * 2 + (5 + 4) * 4)
|
||||
|
||||
/* e_ident[] identification indexes */
|
||||
|
||||
#define EI_MAG0 0 /* File identification byte 0 index */
|
||||
|
||||
@@ -95,10 +95,10 @@ int pdp10_elf36_read_sint36(PDP10_FILE *pdp10fp, pdp10_int36_t *dst)
|
||||
|
||||
int pdp10_elf36_write_ehdr(PDP10_FILE *pdp10fp, const Elf36_Ehdr *ehdr)
|
||||
{
|
||||
if (pdp10_elf36_write_uint36(pdp10fp, ehdr->e_ident1) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_ident2) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_ident3) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_ident4) < 0
|
||||
if (pdp10_elf36_write_uint36(pdp10fp, ehdr->e_wident[0]) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_wident[1]) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_wident[2]) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_wident[3]) < 0
|
||||
|| pdp10_elf36_write_uint18(pdp10fp, ehdr->e_type) < 0
|
||||
|| pdp10_elf36_write_uint18(pdp10fp, ehdr->e_machine) < 0
|
||||
|| pdp10_elf36_write_uint36(pdp10fp, ehdr->e_version) < 0
|
||||
@@ -118,10 +118,10 @@ int pdp10_elf36_write_ehdr(PDP10_FILE *pdp10fp, const Elf36_Ehdr *ehdr)
|
||||
|
||||
int pdp10_elf36_read_ehdr(PDP10_FILE *pdp10fp, Elf36_Ehdr *ehdr)
|
||||
{
|
||||
if (pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_ident1) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_ident2) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_ident3) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_ident4) < 0
|
||||
if (pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_wident[0]) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_wident[1]) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_wident[2]) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_wident[3]) < 0
|
||||
|| pdp10_elf36_read_uint18(pdp10fp, &ehdr->e_type) < 0
|
||||
|| pdp10_elf36_read_uint18(pdp10fp, &ehdr->e_machine) < 0
|
||||
|| pdp10_elf36_read_uint36(pdp10fp, &ehdr->e_version) < 0
|
||||
|
||||
Reference in New Issue
Block a user