Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Wed, 29 Nov 2000 18:41:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Wed, 29 Nov 2000 18:41:00 -0500 Received: from sgi.SGI.COM ([192.48.153.1]:55603 "EHLO sgi.com") by vger.kernel.org with ESMTP id ; Wed, 29 Nov 2000 18:40:54 -0500 X-Mailer: exmh version 2.1.1 10/15/1999 From: Keith Owens To: Linus Torvalds cc: Kernel Mailing List , Alan Cox Subject: [patch] test12-pre3 include/linux/elf.h In-Reply-To: Your message of "Tue, 28 Nov 2000 22:57:35 -0800." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 30 Nov 2000 10:10:16 +1100 Message-ID: <2356.975539416@kao2.melbourne.sgi.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Linus, please apply. The kernel incorrectly defines Elf64_Word and Elf64_Sword as 8 bytes, they should be 4 bytes, Elf64_Xword and Elf64_Sxword are the 8 byte versions. The type mismatch between kernel and user space causes field misalignments if you copy a user space definition into the kernel or vice versa. This patch corrects Elf64_[S]Word to 4 bytes and adds the correct Elf64_[S]Xword where it really needs 8 bytes. It also replaces several other incorrect types in elf.h, they now match user space and the ELF standards. The structures sizes and offsets have not changed, it is just a type cleanup. Patch tested on IA64. It was sent to various 64 bit mailing lists for review, nobody has complained. Index: 0-test12-pre3.1/include/linux/elf.h --- 0-test12-pre3.1/include/linux/elf.h Tue, 31 Oct 2000 08:28:16 +1100 kaos (linux-2.4/Y/0_elf.h 1.4 644) +++ 0-test12-pre3.1(w)/include/linux/elf.h Thu, 30 Nov 2000 10:00:55 +1100 kaos (linux-2.4/Y/0_elf.h 1.4 644) @@ -16,8 +16,10 @@ typedef __u64 Elf64_Addr; typedef __u16 Elf64_Half; typedef __s16 Elf64_SHalf; typedef __u64 Elf64_Off; -typedef __s64 Elf64_Sword; +typedef __s32 Elf64_Sword; -typedef __u64 Elf64_Word; +typedef __u32 Elf64_Word; +typedef __u64 Elf64_Xword; +typedef __s64 Elf64_Sxword; /* These constants are for the segment types stored in the image headers */ #define PT_NULL 0 @@ -176,10 +178,10 @@ typedef struct dynamic{ } Elf32_Dyn; typedef struct { - Elf64_Word d_tag; /* entry tag value */ + Elf64_Sxword d_tag; /* entry tag value */ union { - Elf64_Word d_val; + Elf64_Xword d_val; - Elf64_Word d_ptr; + Elf64_Addr d_ptr; } d_un; } Elf64_Dyn; @@ -370,7 +372,7 @@ typedef struct elf32_rel { typedef struct elf64_rel { Elf64_Addr r_offset; /* Location at which to apply the action */ - Elf64_Word r_info; /* index and type of relocation */ + Elf64_Xword r_info; /* index and type of relocation */ } Elf64_Rel; typedef struct elf32_rela{ @@ -381,8 +383,8 @@ typedef struct elf32_rela{ typedef struct elf64_rela { Elf64_Addr r_offset; /* Location at which to apply the action */ - Elf64_Word r_info; /* index and type of relocation */ + Elf64_Xword r_info; /* index and type of relocation */ - Elf64_Word r_addend; /* Constant addend used to compute value */ + Elf64_Sxword r_addend; /* Constant addend used to compute value */ } Elf64_Rela; typedef struct elf32_sym{ @@ -395,12 +397,12 @@ typedef struct elf32_sym{ } Elf32_Sym; typedef struct elf64_sym { - Elf32_Word st_name; /* Symbol name, index in string tbl (yes, Elf32) */ + Elf64_Word st_name; /* Symbol name, index in string tbl */ unsigned char st_info; /* Type and binding attributes */ unsigned char st_other; /* No defined meaning, 0 */ Elf64_Half st_shndx; /* Associated section index */ Elf64_Addr st_value; /* Value of the symbol */ - Elf64_Word st_size; /* Associated symbol size */ + Elf64_Xword st_size; /* Associated symbol size */ } Elf64_Sym; @@ -425,19 +427,19 @@ typedef struct elf32_hdr{ typedef struct elf64_hdr { unsigned char e_ident[16]; /* ELF "magic number" */ - Elf64_SHalf e_type; + Elf64_Half e_type; Elf64_Half e_machine; - __s32 e_version; + Elf64_Word e_version; Elf64_Addr e_entry; /* Entry point virtual address */ Elf64_Off e_phoff; /* Program header table file offset */ Elf64_Off e_shoff; /* Section header table file offset */ - __s32 e_flags; + Elf64_Word e_flags; - Elf64_SHalf e_ehsize; + Elf64_Half e_ehsize; - Elf64_SHalf e_phentsize; + Elf64_Half e_phentsize; - Elf64_SHalf e_phnum; + Elf64_Half e_phnum; - Elf64_SHalf e_shentsize; + Elf64_Half e_shentsize; - Elf64_SHalf e_shnum; + Elf64_Half e_shnum; - Elf64_SHalf e_shstrndx; + Elf64_Half e_shstrndx; } Elf64_Ehdr; /* These constants define the permissions on sections in the program @@ -458,14 +460,14 @@ typedef struct elf32_phdr{ } Elf32_Phdr; typedef struct elf64_phdr { - __s32 p_type; + Elf64_Word p_type; - __s32 p_flags; + Elf64_Word p_flags; Elf64_Off p_offset; /* Segment file offset */ Elf64_Addr p_vaddr; /* Segment virtual address */ Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Word p_filesz; /* Segment size in file */ + Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Word p_memsz; /* Segment size in memory */ + Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Word p_align; /* Segment alignment, file & memory */ + Elf64_Xword p_align; /* Segment alignment, file & memory */ } Elf64_Phdr; /* sh_type */ @@ -522,16 +524,16 @@ typedef struct { } Elf32_Shdr; typedef struct elf64_shdr { - Elf32_Word sh_name; /* Section name, index in string tbl (yes Elf32) */ + Elf64_Word sh_name; /* Section name, index in string tbl */ - Elf32_Word sh_type; /* Type of section (yes Elf32) */ + Elf64_Word sh_type; /* Type of section */ - Elf64_Word sh_flags; /* Miscellaneous section attributes */ + Elf64_Xword sh_flags; /* Miscellaneous section attributes */ Elf64_Addr sh_addr; /* Section virtual addr at execution */ Elf64_Off sh_offset; /* Section file offset */ - Elf64_Word sh_size; /* Size of section in bytes */ + Elf64_Xword sh_size; /* Size of section in bytes */ - Elf32_Word sh_link; /* Index of another section (yes Elf32) */ + Elf64_Word sh_link; /* Index of another section */ - Elf32_Word sh_info; /* Additional section information (yes Elf32) */ + Elf64_Word sh_info; /* Additional section information */ - Elf64_Word sh_addralign; /* Section alignment */ + Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Word sh_entsize; /* Entry size if section holds table */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ } Elf64_Shdr; #define EI_MAG0 0 /* e_ident[] indexes */ @@ -578,15 +580,10 @@ typedef struct elf32_note { } Elf32_Nhdr; /* Note header in a PT_NOTE section */ -/* - * For now we use the 32 bit version of the structure until we figure - * out whether we need anything better. Note - on the Alpha, "unsigned int" - * is only 32 bits. - */ typedef struct elf64_note { - Elf32_Word n_namesz; /* Name size */ + Elf64_Word n_namesz; /* Name size */ - Elf32_Word n_descsz; /* Content size */ + Elf64_Word n_descsz; /* Content size */ - Elf32_Word n_type; /* Content type */ + Elf64_Word n_type; /* Content type */ } Elf64_Nhdr; #if ELF_CLASS == ELFCLASS32 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/