linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cross-architecture ELF clean up
       [not found] <20070620230854.246399397@goop.org>
@ 2007-06-20 23:08 ` Jeremy Fitzhardinge
  2007-06-21  8:20   ` ian
                     ` (6 more replies)
  0 siblings, 7 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-20 23:08 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: lkml, Andrew Morton, Linux Arch, Richard Henderson, Ian Molton,
	Russell King, Haavard Skinnemoen, Aubrey Li, Mikael Starvik,
	David Howells, Yoshinori Sato, Andi Kleen, Tony Luck,
	Geert Uytterhoeven, Ralf Baechle, Matthew Wilcox, Paul Mackerras,
	Martin Schwidefsky, Paul Mundt, David S. Miller, Miles Bader,
	Chris Zankel

[-- Attachment #1: elf-cleanup.patch --]
[-- Type: text/plain, Size: 74160 bytes --]

This patch cleans up the ELF headers and their users.  It does several
related things:

1. split linux/elf.h into pieces

This splits linux/elf.h into several pieces:
	linux/elf.h		- still the common elf header,
				  functionally unchanged
	linux/elf-const.h	- ELF constants, includable by asm code
	linux/elf-decl.h	- ELF type declarations, without definitions
	linux/elf-defn.h	- ELF type definitions

This makes it easier to use the ELF headers in various contexts such
as assembler and boot code, without pulling in a lot of other unneeded
headers.

2. add asm-*/elf-defines.h, and asm-generic/elf(32|64)-defines.h

Architectures define some arch-specific ELF definitions.

The most basic of these is whether they want to use a 32 or 64 bit ELF
class, and their associated types.  These common definitions have been
put into asm-generic/elf(32|64)-defines.h, so that a simple
architecture can simply include the appropriate generic header in its
asm/elf-defines.h.

The effect of including asm/elf-defines.h in any code is that you get
the architecture's preferred ELF_CLASS defined, and the generic types
(Elf_Ehdr, Elf_Phdr, etc) are defined to the appropriate class types
(Elf32_Ehdr, etc).

For most architectures this transition was straightforward, but some
need special handling:

  mips, powerpc, s390 allow both 32 and 64 bit operation.  powerpc's
  logic for this was particularly complex, so I just copied the code
  outright into asm-powerpc/elf-defines.h and hope that it's right.

  powerpc also appears to have its own duplicate copy of elf.h in
  arch/powerpc/boot/elf.h; presumably because the standard elf.h
  brings in too much.  Update it to just linux/elf-defn.h, which
  should be fine.

  x86-64 does some mucking about with ELF_CLASS in order to make
  fs/binfmt_elf also handle 32-bit binaries.  This is why
  asm-generic/elf(32|64)_defines.h only conditionally define
  ELF_CLASS.

3. Narrow elf.h includes.

Some headers, such as linux/modules.h, are included by a large
proportion of the kernel code, and end up including linux/elf.h which
in turn includes a lot of other headers.  In practice, linux/modules.h
only wants a couple of ELF type declarations, and so can make do with
asm/elf-defines.h, which includes very little.

A side effect of this is that some files were depending on
linux/elf.h's implicit includes, and so needed to have some extra
headers for the definitions they require.

Unfortunately I don't have the means to cross-build all the
architectures, but I did an cross builds of i386, x86-64, sparc64 and
powerpc and fixed up what I found.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Linux Arch <linux-arch@vger.kernel.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ian Molton <spyro@f2s.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Aubrey Li <aubrey.li@analog.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Andi Kleen <ak@suse.de>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Miles Bader <uclinux-v850@lsi.nec.co.jp>
Cc: Chris Zankel <chris@zankel.net>

---
 arch/frv/kernel/process.c                    |    2 
 arch/i386/kernel/smpcommon.c                 |    1 
 arch/i386/kernel/vmi.c                       |    1 
 arch/powerpc/boot/elf.h                      |  145 ---------
 arch/powerpc/kernel/prom_init.c              |    1 
 arch/powerpc/platforms/cell/io-workarounds.c |    1 
 arch/powerpc/platforms/cell/spufs/context.c  |    1 
 arch/powerpc/platforms/pseries/eeh.c         |    1 
 arch/powerpc/platforms/pseries/eeh_event.c   |    1 
 arch/powerpc/platforms/pseries/hotplug-cpu.c |    1 
 arch/powerpc/platforms/pseries/iommu.c       |    1 
 drivers/ps3/sys-manager.c                    |    1 
 include/asm-alpha/elf-defines.h              |    1 
 include/asm-alpha/elf.h                      |    2 
 include/asm-alpha/module.h                   |    8 
 include/asm-arm/elf-defines.h                |    1 
 include/asm-arm/elf.h                        |    2 
 include/asm-arm/module.h                     |    4 
 include/asm-arm26/elf-defines.h              |    1 
 include/asm-arm26/elf.h                      |    2 
 include/asm-avr32/elf-defines.h              |    1 
 include/asm-avr32/elf.h                      |    2 
 include/asm-avr32/module.h                   |    4 
 include/asm-blackfin/elf-defines.h           |    1 
 include/asm-blackfin/elf.h                   |    2 
 include/asm-blackfin/module.h                |    5 
 include/asm-cris/elf-defines.h               |    1 
 include/asm-cris/elf.h                       |    2 
 include/asm-cris/module.h                    |    4 
 include/asm-frv/elf-defines.h                |    1 
 include/asm-frv/elf.h                        |    2 
 include/asm-frv/module.h                     |    4 
 include/asm-generic/Kbuild                   |    2 
 include/asm-generic/Kbuild.asm               |    1 
 include/asm-generic/elf32-defines.h          |   21 +
 include/asm-generic/elf64-defines.h          |   21 +
 include/asm-h8300/elf-defines.h              |    1 
 include/asm-h8300/elf.h                      |    2 
 include/asm-h8300/module.h                   |    5 
 include/asm-i386/elf-defines.h               |   24 +
 include/asm-i386/elf.h                       |   22 -
 include/asm-i386/module.h                    |    4 
 include/asm-ia64/elf-defines.h               |    1 
 include/asm-ia64/elf.h                       |    2 
 include/asm-ia64/module.h                    |    4 
 include/asm-m32r/elf-defines.h               |    1 
 include/asm-m32r/elf.h                       |    2 
 include/asm-m32r/module.h                    |    4 
 include/asm-m68k/elf-defines.h               |    1 
 include/asm-m68k/elf.h                       |    2 
 include/asm-m68k/module.h                    |    5 
 include/asm-m68knommu/elf-defines.h          |    1 
 include/asm-m68knommu/elf.h                  |    2 
 include/asm-mips/elf-defines.h               |    6 
 include/asm-mips/elf.h                       |   15 
 include/asm-mips/module.h                    |   11 
 include/asm-parisc/elf-defines.h             |    5 
 include/asm-parisc/elf.h                     |    6 
 include/asm-parisc/module.h                  |   14 
 include/asm-powerpc/elf-defines.h            |   32 ++
 include/asm-powerpc/elf.h                    |   23 -
 include/asm-powerpc/module.h                 |    7 
 include/asm-s390/elf-defines.h               |    5 
 include/asm-s390/elf.h                       |    6 
 include/asm-s390/module.h                    |    6 
 include/asm-sh/elf-defines.h                 |    1 
 include/asm-sh/elf.h                         |    2 
 include/asm-sh/module.h                      |    4 
 include/asm-sh64/elf-defines.h               |    1 
 include/asm-sh64/elf.h                       |    2 
 include/asm-sh64/module.h                    |    4 
 include/asm-sparc/elf-defines.h              |    1 
 include/asm-sparc/elf.h                      |    2 
 include/asm-sparc/module.h                   |    4 
 include/asm-sparc64/elf-defines.h            |    1 
 include/asm-sparc64/elf.h                    |    2 
 include/asm-sparc64/module.h                 |    4 
 include/asm-v850/elf-defines.h               |    1 
 include/asm-v850/elf.h                       |    2 
 include/asm-v850/module.h                    |    4 
 include/asm-x86_64/elf-defines.h             |    1 
 include/asm-x86_64/elf.h                     |    2 
 include/asm-x86_64/module.h                  |    4 
 include/asm-xtensa/elf-defines.h             |    1 
 include/asm-xtensa/elf.h                     |    2 
 include/asm-xtensa/module.h                  |    4 
 include/linux/Kbuild                         |    4 
 include/linux/audit.h                        |    2 
 include/linux/elf-const.h                    |  222 ++++++++++++++
 include/linux/elf-decl.h                     |   48 +++
 include/linux/elf-defn.h                     |  174 +++++++++++
 include/linux/elf-em.h                       |   51 ---
 include/linux/elf.h                          |  399 +-------------------------
 include/linux/elfnote.h                      |   30 +
 include/linux/module.h                       |    1 
 kernel/sysctl.c                              |    1 
 lib/bug.c                                    |    1 
 97 files changed, 692 insertions(+), 761 deletions(-)

===================================================================
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -309,7 +309,7 @@ unsigned long thread_saved_pc(struct tas
 		return tsk->thread.pc;
 }
 
-int elf_check_arch(const struct elf32_hdr *hdr)
+int elf_check_arch(const Elf32_Ehdr *hdr)
 {
 	unsigned long hsr0 = __get_HSR(0);
 	unsigned long psr = __get_PSR();
===================================================================
--- a/arch/i386/kernel/smpcommon.c
+++ b/arch/i386/kernel/smpcommon.c
@@ -3,6 +3,7 @@
  */
 #include <linux/module.h>
 #include <asm/smp.h>
+#include <asm/desc.h>
 
 DEFINE_PER_CPU(unsigned long, this_cpu_off);
 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
===================================================================
--- a/arch/i386/kernel/vmi.c
+++ b/arch/i386/kernel/vmi.c
@@ -37,6 +37,7 @@
 #include <asm/timer.h>
 #include <asm/vmi_time.h>
 #include <asm/kmap_types.h>
+#include <asm/desc.h>
 
 /* Convenient for calling VMI functions indirectly in the ROM */
 typedef u32 __attribute__((regparm(1))) (VROMFUNC)(void);
===================================================================
--- a/arch/powerpc/boot/elf.h
+++ b/arch/powerpc/boot/elf.h
@@ -1,150 +1,7 @@
 #ifndef _PPC_BOOT_ELF_H_
 #define _PPC_BOOT_ELF_H_
 
-/* 32-bit ELF base types. */
-typedef unsigned int Elf32_Addr;
-typedef unsigned short Elf32_Half;
-typedef unsigned int Elf32_Off;
-typedef signed int Elf32_Sword;
-typedef unsigned int Elf32_Word;
-
-/* 64-bit ELF base types. */
-typedef unsigned long long Elf64_Addr;
-typedef unsigned short Elf64_Half;
-typedef signed short Elf64_SHalf;
-typedef unsigned long long Elf64_Off;
-typedef signed int Elf64_Sword;
-typedef unsigned int Elf64_Word;
-typedef unsigned long long Elf64_Xword;
-typedef signed long long Elf64_Sxword;
-
-/* These constants are for the segment types stored in the image headers */
-#define PT_NULL    0
-#define PT_LOAD    1
-#define PT_DYNAMIC 2
-#define PT_INTERP  3
-#define PT_NOTE    4
-#define PT_SHLIB   5
-#define PT_PHDR    6
-#define PT_TLS     7		/* Thread local storage segment */
-#define PT_LOOS    0x60000000	/* OS-specific */
-#define PT_HIOS    0x6fffffff	/* OS-specific */
-#define PT_LOPROC  0x70000000
-#define PT_HIPROC  0x7fffffff
-#define PT_GNU_EH_FRAME		0x6474e550
-
-#define PT_GNU_STACK	(PT_LOOS + 0x474e551)
-
-/* These constants define the different elf file types */
-#define ET_NONE   0
-#define ET_REL    1
-#define ET_EXEC   2
-#define ET_DYN    3
-#define ET_CORE   4
-#define ET_LOPROC 0xff00
-#define ET_HIPROC 0xffff
-
-/* These constants define the various ELF target machines */
-#define EM_NONE  0
-#define EM_PPC	       20	/* PowerPC */
-#define EM_PPC64       21	/* PowerPC64 */
-
-#define EI_NIDENT	16
-
-typedef struct elf32_hdr {
-	unsigned char e_ident[EI_NIDENT];
-	Elf32_Half e_type;
-	Elf32_Half e_machine;
-	Elf32_Word e_version;
-	Elf32_Addr e_entry;	/* Entry point */
-	Elf32_Off e_phoff;
-	Elf32_Off e_shoff;
-	Elf32_Word e_flags;
-	Elf32_Half e_ehsize;
-	Elf32_Half e_phentsize;
-	Elf32_Half e_phnum;
-	Elf32_Half e_shentsize;
-	Elf32_Half e_shnum;
-	Elf32_Half e_shstrndx;
-} Elf32_Ehdr;
-
-typedef struct elf64_hdr {
-	unsigned char e_ident[16];	/* ELF "magic number" */
-	Elf64_Half e_type;
-	Elf64_Half e_machine;
-	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 */
-	Elf64_Word e_flags;
-	Elf64_Half e_ehsize;
-	Elf64_Half e_phentsize;
-	Elf64_Half e_phnum;
-	Elf64_Half e_shentsize;
-	Elf64_Half e_shnum;
-	Elf64_Half e_shstrndx;
-} Elf64_Ehdr;
-
-/* These constants define the permissions on sections in the program
-   header, p_flags. */
-#define PF_R		0x4
-#define PF_W		0x2
-#define PF_X		0x1
-
-typedef struct elf32_phdr {
-	Elf32_Word p_type;
-	Elf32_Off p_offset;
-	Elf32_Addr p_vaddr;
-	Elf32_Addr p_paddr;
-	Elf32_Word p_filesz;
-	Elf32_Word p_memsz;
-	Elf32_Word p_flags;
-	Elf32_Word p_align;
-} Elf32_Phdr;
-
-typedef struct elf64_phdr {
-	Elf64_Word p_type;
-	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_Xword p_filesz;	/* Segment size in file */
-	Elf64_Xword p_memsz;	/* Segment size in memory */
-	Elf64_Xword p_align;	/* Segment alignment, file & memory */
-} Elf64_Phdr;
-
-#define	EI_MAG0		0	/* e_ident[] indexes */
-#define	EI_MAG1		1
-#define	EI_MAG2		2
-#define	EI_MAG3		3
-#define	EI_CLASS	4
-#define	EI_DATA		5
-#define	EI_VERSION	6
-#define	EI_OSABI	7
-#define	EI_PAD		8
-
-#define	ELFMAG0		0x7f	/* EI_MAG */
-#define	ELFMAG1		'E'
-#define	ELFMAG2		'L'
-#define	ELFMAG3		'F'
-#define	ELFMAG		"\177ELF"
-#define	SELFMAG		4
-
-#define	ELFCLASSNONE	0	/* EI_CLASS */
-#define	ELFCLASS32	1
-#define	ELFCLASS64	2
-#define	ELFCLASSNUM	3
-
-#define ELFDATANONE	0	/* e_ident[EI_DATA] */
-#define ELFDATA2LSB	1
-#define ELFDATA2MSB	2
-
-#define EV_NONE		0	/* e_version, EI_VERSION */
-#define EV_CURRENT	1
-#define EV_NUM		2
-
-#define ELFOSABI_NONE	0
-#define ELFOSABI_LINUX	3
+#include <linux/elf-defn.h>
 
 struct elf_info {
 	unsigned long loadsize;
===================================================================
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -28,6 +28,7 @@
 #include <linux/delay.h>
 #include <linux/initrd.h>
 #include <linux/bitops.h>
+#include <linux/elf.h>
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/page.h>
===================================================================
--- a/arch/powerpc/platforms/cell/io-workarounds.c
+++ b/arch/powerpc/platforms/cell/io-workarounds.c
@@ -9,6 +9,7 @@
 #undef DEBUG
 
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <asm/io.h>
===================================================================
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -23,6 +23,7 @@
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/sched.h>
 #include <asm/spu.h>
 #include <asm/spu_csa.h>
 #include "spufs.h"
===================================================================
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -23,6 +23,7 @@
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/rbtree.h>
+#include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
===================================================================
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -20,6 +20,7 @@
 
 #include <linux/delay.h>
 #include <linux/list.h>
+#include <linux/sched.h>
 #include <linux/mutex.h>
 #include <linux/pci.h>
 #include <linux/workqueue.h>
===================================================================
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -20,6 +20,7 @@
 
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/sched.h>
 #include <linux/cpu.h>
 #include <asm/system.h>
 #include <asm/prom.h>
===================================================================
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -28,6 +28,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
+#include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/pci.h>
===================================================================
--- a/drivers/ps3/sys-manager.c
+++ b/drivers/ps3/sys-manager.c
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/workqueue.h>
+#include <linux/sched.h>
 #include <linux/reboot.h>
 
 #include <asm/firmware.h>
===================================================================
--- /dev/null
+++ b/include/asm-alpha/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf64-defines.h>
===================================================================
--- a/include/asm-alpha/elf.h
+++ b/include/asm-alpha/elf.h
@@ -77,7 +77,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_N
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS64
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_ALPHA
 
===================================================================
--- a/include/asm-alpha/module.h
+++ b/include/asm-alpha/module.h
@@ -6,13 +6,7 @@ struct mod_arch_specific
 	unsigned int gotsecindex;
 };
 
-#define Elf_Sym Elf64_Sym
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Ehdr Elf64_Ehdr
-#define Elf_Phdr Elf64_Phdr
-#define Elf_Dyn Elf64_Dyn
-#define Elf_Rel Elf64_Rel
-#define Elf_Rela Elf64_Rela
+#include <asm/elf-defines.h>
 
 #define ARCH_SHF_SMALL SHF_ALPHA_GPREL
 
===================================================================
--- /dev/null
+++ b/include/asm-arm/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-arm/elf.h
+++ b/include/asm-arm/elf.h
@@ -31,7 +31,7 @@ typedef struct user_fp elf_fpregset_t;
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #ifdef __ARMEB__
 #define ELF_DATA	ELFDATA2MSB
 #else
===================================================================
--- a/include/asm-arm/module.h
+++ b/include/asm-arm/module.h
@@ -6,9 +6,7 @@ struct mod_arch_specific
 	int foo;
 };
 
-#define Elf_Shdr	Elf32_Shdr
-#define Elf_Sym		Elf32_Sym
-#define Elf_Ehdr	Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 /*
  * Include the ARM architecture version.
===================================================================
--- /dev/null
+++ b/include/asm-arm26/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-arm26/elf.h
+++ b/include/asm-arm26/elf.h
@@ -35,7 +35,7 @@ typedef struct { void *null; } elf_fpreg
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_ARM
 
===================================================================
--- /dev/null
+++ b/include/asm-avr32/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-avr32/elf.h
+++ b/include/asm-avr32/elf.h
@@ -69,7 +69,7 @@ typedef struct user_fpu_struct elf_fpreg
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #ifdef __LITTLE_ENDIAN__
 #define ELF_DATA	ELFDATA2LSB
 #else
===================================================================
--- a/include/asm-avr32/module.h
+++ b/include/asm-avr32/module.h
@@ -17,9 +17,7 @@ struct mod_arch_specific {
 	struct mod_arch_syminfo *syminfo;
 };
 
-#define Elf_Shdr		Elf32_Shdr
-#define Elf_Sym			Elf32_Sym
-#define Elf_Ehdr		Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 #define MODULE_PROC_FAMILY "AVR32v1"
 
===================================================================
--- /dev/null
+++ b/include/asm-blackfin/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-blackfin/elf.h
+++ b/include/asm-blackfin/elf.h
@@ -35,7 +35,7 @@ typedef struct user_bfinfp_struct elf_fp
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_BLACKFIN
 
===================================================================
--- a/include/asm-blackfin/module.h
+++ b/include/asm-blackfin/module.h
@@ -3,9 +3,8 @@
 
 #define MODULE_SYMBOL_PREFIX "_"
 
-#define Elf_Shdr        Elf32_Shdr
-#define Elf_Sym         Elf32_Sym
-#define Elf_Ehdr        Elf32_Ehdr
+#include <asm/elf-defines.h>
+
 #define FLG_CODE_IN_L1	0x10
 #define FLG_DATA_IN_L1	0x20
 
===================================================================
--- /dev/null
+++ b/include/asm-cris/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-cris/elf.h
+++ b/include/asm-cris/elf.h
@@ -41,7 +41,7 @@ typedef unsigned long elf_fpregset_t;
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_CRIS
 
===================================================================
--- a/include/asm-cris/module.h
+++ b/include/asm-cris/module.h
@@ -3,7 +3,5 @@
 /* cris is simple */
 struct mod_arch_specific { };
 
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+#include <asm/elf-defines.h>
 #endif /* _ASM_CRIS_MODULE_H */
===================================================================
--- /dev/null
+++ b/include/asm-frv/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-frv/elf.h
+++ b/include/asm-frv/elf.h
@@ -77,7 +77,7 @@ extern int elf_check_arch(const struct e
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2MSB
 #define ELF_ARCH	EM_FRV
 
===================================================================
--- a/include/asm-frv/module.h
+++ b/include/asm-frv/module.h
@@ -15,9 +15,7 @@ struct mod_arch_specific
 {
 };
 
-#define Elf_Shdr	Elf32_Shdr
-#define Elf_Sym		Elf32_Sym
-#define Elf_Ehdr	Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 /*
  * Include the architecture version.
===================================================================
--- a/include/asm-generic/Kbuild
+++ b/include/asm-generic/Kbuild
@@ -1,3 +1,5 @@ header-y += errno-base.h
+header-y += elf32-defines.h
+header-y += elf64-defines.h
 header-y += errno-base.h
 header-y += errno.h
 header-y += fcntl.h
===================================================================
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -1,6 +1,7 @@ unifdef-y += a.out.h
 unifdef-y += a.out.h
 unifdef-y += auxvec.h
 unifdef-y += byteorder.h
+unifdef-y += elf-defines.h
 unifdef-y += errno.h
 unifdef-y += fcntl.h
 unifdef-y += ioctl.h
===================================================================
--- /dev/null
+++ b/include/asm-generic/elf32-defines.h
@@ -0,0 +1,21 @@
+#ifndef __ASM_GENERIC_ELF32_DEFINES_H
+#define __ASM_GENERIC_ELF32_DEFINES_H
+
+#include <linux/elf-decl.h>
+#include <linux/elf-const.h>
+
+#ifndef ELF_CLASS
+#define ELF_CLASS	ELFCLASS32
+#endif
+
+typedef Elf32_Ehdr	Elf_Ehdr;
+typedef Elf32_Phdr	Elf_Phdr;
+typedef Elf32_Shdr	Elf_Shdr;
+typedef Elf32_Sym	Elf_Sym;
+typedef Elf32_Dyn	Elf_Dyn;
+typedef Elf32_Rel	Elf_Rel;
+typedef Elf32_Rela	Elf_Rela;
+
+typedef Elf32_Addr	Elf_Addr;
+
+#endif /* __ASM_GENERIC_ELF32_DEFINES_H */
===================================================================
--- /dev/null
+++ b/include/asm-generic/elf64-defines.h
@@ -0,0 +1,21 @@
+#ifndef __ASM_GENERIC_ELF64_DEFINES_H
+#define __ASM_GENERIC_ELF64_DEFINES_H
+
+#include <linux/elf-decl.h>
+#include <linux/elf-const.h>
+
+#ifndef ELF_CLASS
+#define ELF_CLASS	ELFCLASS64
+#endif
+
+typedef Elf64_Ehdr	Elf_Ehdr;
+typedef Elf64_Phdr	Elf_Phdr;
+typedef Elf64_Shdr	Elf_Shdr;
+typedef Elf64_Sym	Elf_Sym;
+typedef Elf64_Dyn	Elf_Dyn;
+typedef Elf64_Rel	Elf_Rel;
+typedef Elf64_Rela	Elf_Rela;
+
+typedef Elf64_Addr	Elf_Addr;
+
+#endif /* __ASM_GENERIC_ELF64_DEFINES_H */
===================================================================
--- /dev/null
+++ b/include/asm-h8300/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-h8300/elf.h
+++ b/include/asm-h8300/elf.h
@@ -22,7 +22,7 @@ typedef unsigned long elf_fpregset_t;
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2MSB
 #define ELF_ARCH	EM_H8_300
 #if defined(__H8300H__)
===================================================================
--- a/include/asm-h8300/module.h
+++ b/include/asm-h8300/module.h
@@ -4,9 +4,8 @@
  * This file contains the H8/300 architecture specific module code.
  */
 struct mod_arch_specific { };
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+
+#include <asm/elf-defines.h>
 
 #define MODULE_SYMBOL_PREFIX "_"
 
===================================================================
--- /dev/null
+++ b/include/asm-i386/elf-defines.h
@@ -0,0 +1,24 @@
+#ifndef __ASM_I386_ELF_DEFINES_H
+#define __ASM_I386_ELF_DEFINES_H
+
+#define R_386_NONE	0
+#define R_386_32	1
+#define R_386_PC32	2
+#define R_386_GOT32	3
+#define R_386_PLT32	4
+#define R_386_COPY	5
+#define R_386_GLOB_DAT	6
+#define R_386_JMP_SLOT	7
+#define R_386_RELATIVE	8
+#define R_386_GOTOFF	9
+#define R_386_GOTPC	10
+#define R_386_NUM	11
+
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#include <asm-generic/elf32-defines.h>
+#define ELF_DATA	ELFDATA2LSB
+#define ELF_ARCH	EM_386
+
+#endif /* __ASM_I386_ELF_DEFINES_H */
===================================================================
--- a/include/asm-i386/elf.h
+++ b/include/asm-i386/elf.h
@@ -5,22 +5,9 @@
  * ELF register definitions..
  */
 
-#include <asm/ptrace.h>
 #include <asm/user.h>
 #include <asm/auxvec.h>
-
-#define R_386_NONE	0
-#define R_386_32	1
-#define R_386_PC32	2
-#define R_386_GOT32	3
-#define R_386_PLT32	4
-#define R_386_COPY	5
-#define R_386_GLOB_DAT	6
-#define R_386_JMP_SLOT	7
-#define R_386_RELATIVE	8
-#define R_386_GOTOFF	9
-#define R_386_GOTPC	10
-#define R_386_NUM	11
+#include <asm/elf-defines.h>
 
 typedef unsigned long elf_greg_t;
 
@@ -35,13 +22,6 @@ typedef struct user_fxsr_struct elf_fpxr
  */
 #define elf_check_arch(x) \
 	(((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
-
-/*
- * These are used to set parameters in the core dumps.
- */
-#define ELF_CLASS	ELFCLASS32
-#define ELF_DATA	ELFDATA2LSB
-#define ELF_ARCH	EM_386
 
 #ifdef __KERNEL__
 
===================================================================
--- a/include/asm-i386/module.h
+++ b/include/asm-i386/module.h
@@ -6,9 +6,7 @@ struct mod_arch_specific
 {
 };
 
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 #ifdef CONFIG_M386
 #define MODULE_PROC_FAMILY "386 "
===================================================================
--- /dev/null
+++ b/include/asm-ia64/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf64-defines.h>
===================================================================
--- a/include/asm-ia64/elf.h
+++ b/include/asm-ia64/elf.h
@@ -21,7 +21,7 @@
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS64
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_IA_64
 
===================================================================
--- a/include/asm-ia64/module.h
+++ b/include/asm-ia64/module.h
@@ -23,9 +23,7 @@ struct mod_arch_specific {
 	unsigned int next_got_entry;	/* index of next available got entry */
 };
 
-#define Elf_Shdr	Elf64_Shdr
-#define Elf_Sym		Elf64_Sym
-#define Elf_Ehdr	Elf64_Ehdr
+#include <asm/elf-defines.h>
 
 #define MODULE_PROC_FAMILY	"ia64"
 #define MODULE_ARCH_VERMAGIC	MODULE_PROC_FAMILY \
===================================================================
--- /dev/null
+++ b/include/asm-m32r/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-m32r/elf.h
+++ b/include/asm-m32r/elf.h
@@ -81,7 +81,7 @@ typedef elf_fpreg_t elf_fpregset_t;
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #if defined(__LITTLE_ENDIAN)
 #define ELF_DATA	ELFDATA2LSB
 #elif defined(__BIG_ENDIAN)
===================================================================
--- a/include/asm-m32r/module.h
+++ b/include/asm-m32r/module.h
@@ -3,8 +3,6 @@
 
 struct mod_arch_specific { };
 
-#define Elf_Shdr	Elf32_Shdr
-#define Elf_Sym		Elf32_Sym
-#define Elf_Ehdr	Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 #endif /* _ASM_M32R_MODULE_H */
===================================================================
--- /dev/null
+++ b/include/asm-m68k/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-m68k/elf.h
+++ b/include/asm-m68k/elf.h
@@ -50,7 +50,7 @@ typedef struct user_m68kfp_struct elf_fp
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2MSB
 #define ELF_ARCH	EM_68K
 
===================================================================
--- a/include/asm-m68k/module.h
+++ b/include/asm-m68k/module.h
@@ -10,10 +10,7 @@ struct mod_arch_specific {
 	.fixup_end		= __stop_fixup,		\
 }
 
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
-
+#include <asm/elf-defines.h>
 
 enum m68k_fixup_type {
 	m68k_fixup_memoffset,
===================================================================
--- /dev/null
+++ b/include/asm-m68knommu/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-m68knommu/elf.h
+++ b/include/asm-m68knommu/elf.h
@@ -50,7 +50,7 @@ typedef struct user_m68kfp_struct elf_fp
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2MSB
 #define ELF_ARCH	EM_68K
 
===================================================================
--- /dev/null
+++ b/include/asm-mips/elf-defines.h
@@ -0,0 +1,6 @@
+#ifdef CONFIG_64BIT
+#include <asm-generic/elf64-defines.h>
+#endif
+#ifdef CONFIG_32BIT
+#include <asm-generic/elf32-defines.h>
+#endif
===================================================================
--- a/include/asm-mips/elf.h
+++ b/include/asm-mips/elf.h
@@ -173,6 +173,11 @@ typedef double elf_fpreg_t;
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
+/*
+ * These are used to set parameters in the core dumps.
+ */
+#include <asm/elf-defines.h>
+
 #ifdef CONFIG_32BIT
 
 /*
@@ -196,11 +201,6 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_N
 	__res;								\
 })
 
-/*
- * These are used to set parameters in the core dumps.
- */
-#define ELF_CLASS	ELFCLASS32
-
 #endif /* CONFIG_32BIT */
 
 #ifdef CONFIG_64BIT
@@ -219,11 +219,6 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_N
 									\
 	__res;								\
 })
-
-/*
- * These are used to set parameters in the core dumps.
- */
-#define ELF_CLASS	ELFCLASS64
 
 #endif /* CONFIG_64BIT */
 
===================================================================
--- a/include/asm-mips/module.h
+++ b/include/asm-mips/module.h
@@ -3,6 +3,7 @@
 
 #include <linux/list.h>
 #include <asm/uaccess.h>
+#include <asm/elf-defines.h>
 
 struct mod_arch_specific {
 	/* Data Bus Error exception tables */
@@ -34,11 +35,6 @@ typedef struct {
 
 #ifdef CONFIG_32BIT
 
-#define Elf_Shdr	Elf32_Shdr
-#define Elf_Sym		Elf32_Sym
-#define Elf_Ehdr	Elf32_Ehdr
-#define Elf_Addr	Elf32_Addr
-
 #define Elf_Mips_Rel	Elf32_Rel
 #define Elf_Mips_Rela	Elf32_Rela
 
@@ -48,11 +44,6 @@ typedef struct {
 #endif
 
 #ifdef CONFIG_64BIT
-
-#define Elf_Shdr	Elf64_Shdr
-#define Elf_Sym		Elf64_Sym
-#define Elf_Ehdr	Elf64_Ehdr
-#define Elf_Addr	Elf64_Addr
 
 #define Elf_Mips_Rel	Elf64_Mips_Rel
 #define Elf_Mips_Rela	Elf64_Mips_Rela
===================================================================
--- /dev/null
+++ b/include/asm-parisc/elf-defines.h
@@ -0,0 +1,5 @@
+#ifdef CONFIG_64BIT
+#include <asm-generic/elf64-defines.h>
+#else
+#include <asm-generic/elf32-defines.h>
+#endif
===================================================================
--- a/include/asm-parisc/elf.h
+++ b/include/asm-parisc/elf.h
@@ -220,11 +220,7 @@ typedef struct elf64_fdesc {
  * macros, and then it includes fs/binfmt_elf.c to provide an alternate
  * elf binary handler for 32 bit binaries (on the 64 bit kernel).
  */
-#ifdef CONFIG_64BIT
-#define ELF_CLASS       ELFCLASS64
-#else
-#define ELF_CLASS	ELFCLASS32
-#endif
+#include <asm/elf-defines.h>
 
 typedef unsigned long elf_greg_t;
 
===================================================================
--- a/include/asm-parisc/module.h
+++ b/include/asm-parisc/module.h
@@ -3,19 +3,7 @@
 /*
  * This file contains the parisc architecture specific module code.
  */
-#ifdef CONFIG_64BIT
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Sym Elf64_Sym
-#define Elf_Ehdr Elf64_Ehdr
-#define Elf_Addr Elf64_Addr
-#define Elf_Rela Elf64_Rela
-#else
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
-#define Elf_Addr Elf32_Addr
-#define Elf_Rela Elf32_Rela
-#endif
+#include <asm/elf-defines.h>
 
 struct unwind_table;
 
===================================================================
--- /dev/null
+++ b/include/asm-powerpc/elf-defines.h
@@ -0,0 +1,32 @@
+#ifndef _ASM_POWERPC_ELF_DEFINES_H
+#define _ASM_POWERPC_ELF_DEFINES_H
+
+#include <linux/elf-const.h>
+
+/*
+ * ELF_ARCH, CLASS, and DATA are used to set parameters in the core dumps.
+ */
+#ifdef __powerpc64__
+# define ELF_NVRREG32	33	/* includes vscr & vrsave stuffed together */
+# define ELF_NVRREG	34	/* includes vscr & vrsave in split vectors */
+# define ELF_GREG_TYPE	elf_greg_t64
+#else
+# define ELF_NEVRREG	34	/* includes acc (as 2) */
+# define ELF_NVRREG	33	/* includes vscr */
+# define ELF_GREG_TYPE	elf_greg_t32
+# define ELF_ARCH	EM_PPC
+# define ELF_CLASS	ELFCLASS32
+# define ELF_DATA	ELFDATA2MSB
+#endif /* __powerpc64__ */
+
+#ifndef ELF_ARCH
+# include <asm-generic/elf64-defines.h>
+# define ELF_ARCH	EM_PPC64
+# define ELF_CLASS	ELFCLASS64
+# define ELF_DATA	ELFDATA2MSB
+#else
+  /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
+# include <asm-generic/elf32-defines.h>
+#endif
+
+#endif	/* _ASM_POWERPC_ELF_DEFINES_H */
===================================================================
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -102,26 +102,9 @@ typedef unsigned int elf_greg_t32;
 typedef unsigned int elf_greg_t32;
 typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
 
-/*
- * ELF_ARCH, CLASS, and DATA are used to set parameters in the core dumps.
- */
-#ifdef __powerpc64__
-# define ELF_NVRREG32	33	/* includes vscr & vrsave stuffed together */
-# define ELF_NVRREG	34	/* includes vscr & vrsave in split vectors */
-# define ELF_GREG_TYPE	elf_greg_t64
-#else
-# define ELF_NEVRREG	34	/* includes acc (as 2) */
-# define ELF_NVRREG	33	/* includes vscr */
-# define ELF_GREG_TYPE	elf_greg_t32
-# define ELF_ARCH	EM_PPC
-# define ELF_CLASS	ELFCLASS32
-# define ELF_DATA	ELFDATA2MSB
-#endif /* __powerpc64__ */
-
-#ifndef ELF_ARCH
-# define ELF_ARCH	EM_PPC64
-# define ELF_CLASS	ELFCLASS64
-# define ELF_DATA	ELFDATA2MSB
+#include <asm/elf-defines.h>
+
+#if ELF_ARCH == EM_PPC64
   typedef elf_greg_t64 elf_greg_t;
   typedef elf_gregset_t64 elf_gregset_t;
 #else
===================================================================
--- a/include/asm-powerpc/module.h
+++ b/include/asm-powerpc/module.h
@@ -50,18 +50,13 @@ struct mod_arch_specific {
  * Select ELF headers.
  * Make empty section for module_frob_arch_sections to expand.
  */
+#include <asm/elf-defines.h>
 
 #ifdef __powerpc64__
-#    define Elf_Shdr	Elf64_Shdr
-#    define Elf_Sym	Elf64_Sym
-#    define Elf_Ehdr	Elf64_Ehdr
 #    ifdef MODULE
 	asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
 #    endif
 #else
-#    define Elf_Shdr	Elf32_Shdr
-#    define Elf_Sym	Elf32_Sym
-#    define Elf_Ehdr	Elf32_Ehdr
 #    ifdef MODULE
 	asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
 	asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
===================================================================
--- /dev/null
+++ b/include/asm-s390/elf-defines.h
@@ -0,0 +1,5 @@
+#ifndef __s390x__
+#include <asm-generic/elf32-defines.h>
+#else
+#include <asm-generic/elf64-defines.h>
+#endif
===================================================================
--- a/include/asm-s390/elf.h
+++ b/include/asm-s390/elf.h
@@ -95,11 +95,7 @@
 /*
  * These are used to set parameters in the core dumps.
  */
-#ifndef __s390x__
-#define ELF_CLASS	ELFCLASS32
-#else /* __s390x__ */
-#define ELF_CLASS	ELFCLASS64
-#endif /* __s390x__ */
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2MSB
 #define ELF_ARCH	EM_S390
 
===================================================================
--- a/include/asm-s390/module.h
+++ b/include/asm-s390/module.h
@@ -28,6 +28,7 @@ struct mod_arch_specific
 	struct mod_arch_syminfo *syminfo;
 };
 
+#include <asm/elf-defines.h>
 #ifdef __s390x__
 #define ElfW(x) Elf64_ ## x
 #define ELFW(x) ELF64_ ## x
@@ -36,11 +37,6 @@ struct mod_arch_specific
 #define ELFW(x) ELF32_ ## x
 #endif
 
-#define Elf_Addr ElfW(Addr)
-#define Elf_Rela ElfW(Rela)
-#define Elf_Shdr ElfW(Shdr)
-#define Elf_Sym ElfW(Sym)
-#define Elf_Ehdr ElfW(Ehdr)
 #define ELF_R_SYM ELFW(R_SYM)
 #define ELF_R_TYPE ELFW(R_TYPE)
 #endif /* _ASM_S390_MODULE_H */
===================================================================
--- /dev/null
+++ b/include/asm-sh/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -65,7 +65,7 @@ typedef struct user_fpu_struct elf_fpreg
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #ifdef __LITTLE_ENDIAN__
 #define ELF_DATA	ELFDATA2LSB
 #else
===================================================================
--- a/include/asm-sh/module.h
+++ b/include/asm-sh/module.h
@@ -9,9 +9,7 @@ struct mod_arch_specific {
 	/* Nothing to see here .. */
 };
 
-#define Elf_Shdr		Elf32_Shdr
-#define Elf_Sym			Elf32_Sym
-#define Elf_Ehdr		Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 #ifdef CONFIG_CPU_LITTLE_ENDIAN
 # ifdef CONFIG_CPU_SH2
===================================================================
--- /dev/null
+++ b/include/asm-sh64/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-sh64/elf.h
+++ b/include/asm-sh64/elf.h
@@ -35,7 +35,7 @@ typedef struct user_fpu_struct elf_fpreg
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #ifdef __LITTLE_ENDIAN__
 #define ELF_DATA	ELFDATA2LSB
 #else
===================================================================
--- a/include/asm-sh64/module.h
+++ b/include/asm-sh64/module.h
@@ -8,9 +8,7 @@ struct mod_arch_specific {
 	/* empty */
 };
 
-#define Elf_Shdr		Elf32_Shdr
-#define Elf_Sym			Elf32_Sym
-#define Elf_Ehdr		Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 #define module_map(x)		vmalloc(x)
 #define module_unmap(x)		vfree(x)
===================================================================
--- /dev/null
+++ b/include/asm-sparc/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-sparc/elf.h
+++ b/include/asm-sparc/elf.h
@@ -125,7 +125,7 @@ do {	unsigned long *dest = &(__elf_regs[
  * These are used to set parameters in the core dumps.
  */
 #define ELF_ARCH	EM_SPARC
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2MSB
 
 #define USE_ELF_CORE_DUMP
===================================================================
--- a/include/asm-sparc/module.h
+++ b/include/asm-sparc/module.h
@@ -1,7 +1,5 @@
 #ifndef _ASM_SPARC_MODULE_H
 #define _ASM_SPARC_MODULE_H
 struct mod_arch_specific { };
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+#include <asm/elf-defines.h>
 #endif /* _ASM_SPARC_MODULE_H */
===================================================================
--- /dev/null
+++ b/include/asm-sparc64/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf64-defines.h>
===================================================================
--- a/include/asm-sparc64/elf.h
+++ b/include/asm-sparc64/elf.h
@@ -75,8 +75,8 @@
  * These are used to set parameters in the core dumps.
  */
 #ifndef ELF_ARCH
+#include <asm/elf-defines.h>
 #define ELF_ARCH		EM_SPARCV9
-#define ELF_CLASS		ELFCLASS64
 #define ELF_DATA		ELFDATA2MSB
 
 typedef unsigned long elf_greg_t;
===================================================================
--- a/include/asm-sparc64/module.h
+++ b/include/asm-sparc64/module.h
@@ -1,7 +1,5 @@
 #ifndef _ASM_SPARC64_MODULE_H
 #define _ASM_SPARC64_MODULE_H
 struct mod_arch_specific { };
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Sym Elf64_Sym
-#define Elf_Ehdr Elf64_Ehdr
+#include <asm/elf-defines.h>
 #endif /* _ASM_SPARC64_MODULE_H */
===================================================================
--- /dev/null
+++ b/include/asm-v850/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-v850/elf.h
+++ b/include/asm-v850/elf.h
@@ -50,7 +50,7 @@ typedef struct user_fpu_struct elf_fpreg
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #ifdef __LITTLE_ENDIAN__
 #define ELF_DATA	ELFDATA2LSB
 #else
===================================================================
--- a/include/asm-v850/module.h
+++ b/include/asm-v850/module.h
@@ -31,9 +31,7 @@ struct mod_arch_specific
 	unsigned int core_plt_section, init_plt_section;
 };
 
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 /* Make empty sections for module_frob_arch_sections to expand. */
 #ifdef MODULE
===================================================================
--- /dev/null
+++ b/include/asm-x86_64/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf64-defines.h>
===================================================================
--- a/include/asm-x86_64/elf.h
+++ b/include/asm-x86_64/elf.h
@@ -39,7 +39,7 @@ typedef struct user_i387_struct elf_fpre
 /*
  * These are used to set parameters in the core dumps.
  */
-#define ELF_CLASS	ELFCLASS64
+#include <asm/elf-defines.h>
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_X86_64
 
===================================================================
--- a/include/asm-x86_64/module.h
+++ b/include/asm-x86_64/module.h
@@ -3,8 +3,6 @@
 
 struct mod_arch_specific {}; 
 
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Sym Elf64_Sym
-#define Elf_Ehdr Elf64_Ehdr
+#include <asm/elf-defines.h>
 
 #endif 
===================================================================
--- /dev/null
+++ b/include/asm-xtensa/elf-defines.h
@@ -0,0 +1,1 @@
+#include <asm-generic/elf32-defines.h>
===================================================================
--- a/include/asm-xtensa/elf.h
+++ b/include/asm-xtensa/elf.h
@@ -153,7 +153,7 @@ extern void xtensa_elf_core_copy_regs (x
 # error processor byte order undefined!
 #endif
 
-#define ELF_CLASS	ELFCLASS32
+#include <asm/elf-defines.h>
 #define ELF_ARCH	EM_XTENSA
 
 #define USE_ELF_CORE_DUMP
===================================================================
--- a/include/asm-xtensa/module.h
+++ b/include/asm-xtensa/module.h
@@ -18,8 +18,6 @@ struct mod_arch_specific
 	/* Module support is not completely implemented. */
 };
 
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+#include <asm/elf-defines.h>
 
 #endif	/* _XTENSA_MODULE_H */
===================================================================
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -58,7 +58,9 @@ header-y += efs_fs_sb.h
 header-y += efs_fs_sb.h
 header-y += elf-fdpic.h
 header-y += elf.h
-header-y += elf-em.h
+header-y += elf-const.h
+header-y += elf-decl.h
+header-y += elf-defn.h
 header-y += fadvise.h
 header-y += fd.h
 header-y += fdreg.h
===================================================================
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -25,7 +25,7 @@
 #define _LINUX_AUDIT_H_
 
 #include <linux/types.h>
-#include <linux/elf-em.h>
+#include <linux/elf-const.h>
 
 /* The netlink messages for the audit system is divided into blocks:
  * 1000 - 1099 are for commanding the audit system
===================================================================
--- /dev/null
+++ b/include/linux/elf-const.h
@@ -0,0 +1,222 @@
+#ifndef _LINUX_ELF_CONST_H
+#define _LINUX_ELF_CONST_H
+
+/* These constants define the various ELF target machines */
+#define EM_NONE		0
+#define EM_M32		1
+#define EM_SPARC	2
+#define EM_386		3
+#define EM_68K		4
+#define EM_88K		5
+#define EM_486		6	/* Perhaps disused */
+#define EM_860		7
+#define EM_MIPS		8	/* MIPS R3000 (officially, big-endian only) */
+				/* Next two are historical and binaries and
+				   modules of these types will be rejected by
+				   Linux.  */
+#define EM_MIPS_RS3_LE	10	/* MIPS R3000 little-endian */
+#define EM_MIPS_RS4_BE	10	/* MIPS R4000 big-endian */
+
+#define EM_PARISC	15	/* HPPA */
+#define EM_SPARC32PLUS	18	/* Sun's "v8plus" */
+#define EM_PPC		20	/* PowerPC */
+#define EM_PPC64	21       /* PowerPC64 */
+#define EM_SH		42	/* SuperH */
+#define EM_SPARCV9	43	/* SPARC v9 64-bit */
+#define EM_IA_64	50	/* HP/Intel IA-64 */
+#define EM_X86_64	62	/* AMD x86-64 */
+#define EM_S390		22	/* IBM S/390 */
+#define EM_CRIS		76	/* Axis Communications 32-bit embedded processor */
+#define EM_V850		87	/* NEC v850 */
+#define EM_M32R		88	/* Renesas M32R */
+#define EM_H8_300	46	/* Renesas H8/300,300H,H8S */
+#define EM_BLACKFIN     106     /* ADI Blackfin Processor */
+#define EM_FRV		0x5441	/* Fujitsu FR-V */
+#define EM_AVR32	0x18ad	/* Atmel AVR32 */
+
+/*
+ * This is an interim value that we will use until the committee comes
+ * up with a final number.
+ */
+#define EM_ALPHA	0x9026
+
+/* Bogus old v850 magic number, used by old tools. */
+#define EM_CYGNUS_V850	0x9080
+/* Bogus old m32r magic number, used by old tools. */
+#define EM_CYGNUS_M32R	0x9041
+/* This is the old interim value for S/390 architecture */
+#define EM_S390_OLD	0xA390
+
+#define EI_NIDENT	16
+
+/* These constants define the permissions on sections in the program
+   header, p_flags. */
+#define PF_R		0x4
+#define PF_W		0x2
+#define PF_X		0x1
+
+/* These constants are for the segment types stored in the image headers */
+#define PT_NULL    0
+#define PT_LOAD    1
+#define PT_DYNAMIC 2
+#define PT_INTERP  3
+#define PT_NOTE    4
+#define PT_SHLIB   5
+#define PT_PHDR    6
+#define PT_TLS     7               /* Thread local storage segment */
+#define PT_LOOS    0x60000000      /* OS-specific */
+#define PT_HIOS    0x6fffffff      /* OS-specific */
+#define PT_LOPROC  0x70000000
+#define PT_HIPROC  0x7fffffff
+#define PT_GNU_EH_FRAME		0x6474e550
+
+#define PT_GNU_STACK	(PT_LOOS + 0x474e551)
+
+/* These constants define the different elf file types */
+#define ET_NONE   0
+#define ET_REL    1
+#define ET_EXEC   2
+#define ET_DYN    3
+#define ET_CORE   4
+#define ET_LOPROC 0xff00
+#define ET_HIPROC 0xffff
+
+/* This is the info that is needed to parse the dynamic section of the file */
+#define DT_NULL		0
+#define DT_NEEDED	1
+#define DT_PLTRELSZ	2
+#define DT_PLTGOT	3
+#define DT_HASH		4
+#define DT_STRTAB	5
+#define DT_SYMTAB	6
+#define DT_RELA		7
+#define DT_RELASZ	8
+#define DT_RELAENT	9
+#define DT_STRSZ	10
+#define DT_SYMENT	11
+#define DT_INIT		12
+#define DT_FINI		13
+#define DT_SONAME	14
+#define DT_RPATH 	15
+#define DT_SYMBOLIC	16
+#define DT_REL	        17
+#define DT_RELSZ	18
+#define DT_RELENT	19
+#define DT_PLTREL	20
+#define DT_DEBUG	21
+#define DT_TEXTREL	22
+#define DT_JMPREL	23
+#define DT_ENCODING	32
+#define OLD_DT_LOOS	0x60000000
+#define DT_LOOS		0x6000000d
+#define DT_HIOS		0x6ffff000
+#define DT_VALRNGLO	0x6ffffd00
+#define DT_VALRNGHI	0x6ffffdff
+#define DT_ADDRRNGLO	0x6ffffe00
+#define DT_ADDRRNGHI	0x6ffffeff
+#define DT_VERSYM	0x6ffffff0
+#define DT_RELACOUNT	0x6ffffff9
+#define DT_RELCOUNT	0x6ffffffa
+#define DT_FLAGS_1	0x6ffffffb
+#define DT_VERDEF	0x6ffffffc
+#define	DT_VERDEFNUM	0x6ffffffd
+#define DT_VERNEED	0x6ffffffe
+#define	DT_VERNEEDNUM	0x6fffffff
+#define OLD_DT_HIOS     0x6fffffff
+#define DT_LOPROC	0x70000000
+#define DT_HIPROC	0x7fffffff
+
+/* This info is needed when parsing the symbol table */
+#define STB_LOCAL  0
+#define STB_GLOBAL 1
+#define STB_WEAK   2
+
+#define STT_NOTYPE  0
+#define STT_OBJECT  1
+#define STT_FUNC    2
+#define STT_SECTION 3
+#define STT_FILE    4
+#define STT_COMMON  5
+#define STT_TLS     6
+
+/* sh_type */
+#define SHT_NULL	0
+#define SHT_PROGBITS	1
+#define SHT_SYMTAB	2
+#define SHT_STRTAB	3
+#define SHT_RELA	4
+#define SHT_HASH	5
+#define SHT_DYNAMIC	6
+#define SHT_NOTE	7
+#define SHT_NOBITS	8
+#define SHT_REL		9
+#define SHT_SHLIB	10
+#define SHT_DYNSYM	11
+#define SHT_NUM		12
+#define SHT_LOPROC	0x70000000
+#define SHT_HIPROC	0x7fffffff
+#define SHT_LOUSER	0x80000000
+#define SHT_HIUSER	0xffffffff
+
+/* sh_flags */
+#define SHF_WRITE	0x1
+#define SHF_ALLOC	0x2
+#define SHF_EXECINSTR	0x4
+#define SHF_MASKPROC	0xf0000000
+
+/* special section indexes */
+#define SHN_UNDEF	0
+#define SHN_LORESERVE	0xff00
+#define SHN_LOPROC	0xff00
+#define SHN_HIPROC	0xff1f
+#define SHN_ABS		0xfff1
+#define SHN_COMMON	0xfff2
+#define SHN_HIRESERVE	0xffff
+
+#define	EI_MAG0		0		/* e_ident[] indexes */
+#define	EI_MAG1		1
+#define	EI_MAG2		2
+#define	EI_MAG3		3
+#define	EI_CLASS	4
+#define	EI_DATA		5
+#define	EI_VERSION	6
+#define	EI_OSABI	7
+#define	EI_PAD		8
+
+#define	ELFMAG0		0x7f		/* EI_MAG */
+#define	ELFMAG1		'E'
+#define	ELFMAG2		'L'
+#define	ELFMAG3		'F'
+#define	ELFMAG		"\177ELF"
+#define	SELFMAG		4
+
+#define	ELFCLASSNONE	0		/* EI_CLASS */
+#define	ELFCLASS32	1
+#define	ELFCLASS64	2
+#define	ELFCLASSNUM	3
+
+#define ELFDATANONE	0		/* e_ident[EI_DATA] */
+#define ELFDATA2LSB	1
+#define ELFDATA2MSB	2
+
+#define EV_NONE		0		/* e_version, EI_VERSION */
+#define EV_CURRENT	1
+#define EV_NUM		2
+
+#define ELFOSABI_NONE	0
+#define ELFOSABI_LINUX	3
+#define ELFOSABI_STANDALONE	255
+
+#ifndef ELF_OSABI
+#define ELF_OSABI ELFOSABI_NONE
+#endif
+
+/* Notes used in ET_CORE */
+#define NT_PRSTATUS	1
+#define NT_PRFPREG	2
+#define NT_PRPSINFO	3
+#define NT_TASKSTRUCT	4
+#define NT_AUXV		6
+#define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */
+
+#endif /* _LINUX_ELF_CONST_H */
===================================================================
--- /dev/null
+++ b/include/linux/elf-decl.h
@@ -0,0 +1,48 @@
+#ifndef _LINUX_ELF_DECL_H
+#define _LINUX_ELF_DECL_H
+
+#include <linux/types.h>
+
+/* 32-bit ELF base types. */
+typedef __u32	Elf32_Addr;
+typedef __u16	Elf32_Half;
+typedef __u32	Elf32_Off;
+typedef __s32	Elf32_Sword;
+typedef __u32	Elf32_Word;
+
+/* 64-bit ELF base types. */
+typedef __u64	Elf64_Addr;
+typedef __u16	Elf64_Half;
+typedef __s16	Elf64_SHalf;
+typedef __u64	Elf64_Off;
+typedef __s32	Elf64_Sword;
+typedef __u32	Elf64_Word;
+typedef __u64	Elf64_Xword;
+typedef __s64	Elf64_Sxword;
+
+typedef struct Elf32_Dyn Elf32_Dyn;
+typedef struct Elf64_Dyn Elf64_Dyn;
+
+typedef struct Elf32_Rel Elf32_Rel;
+typedef struct Elf64_Rel Elf64_Rel;
+
+typedef struct Elf32_Rela Elf32_Rela;
+typedef struct Elf64_Rela Elf64_Rela;
+
+typedef struct Elf32_Sym Elf32_Sym;
+typedef struct Elf64_Sym Elf64_Sym;
+
+typedef struct Elf32_Ehdr Elf32_Ehdr;
+typedef struct Elf64_Ehdr Elf64_Ehdr;
+
+typedef struct Elf32_Phdr Elf32_Phdr;
+typedef struct Elf64_Phdr Elf64_Phdr;
+
+typedef struct Elf32_Shdr Elf32_Shdr;
+typedef struct Elf64_Shdr Elf64_Shdr;
+
+typedef struct Elf32_Nhdr Elf32_Nhdr;
+typedef struct Elf64_Nhdr Elf64_Nhdr;
+
+
+#endif /* _LINUX_ELF_DECL_H */
===================================================================
--- /dev/null
+++ b/include/linux/elf-defn.h
@@ -0,0 +1,174 @@
+#ifndef _LINUX_ELF_DEFN_H
+#define _LINUX_ELF_DEFN_H
+
+#include <linux/elf-decl.h>
+#include <linux/elf-const.h>
+
+#define ELF_ST_BIND(x)		((x) >> 4)
+#define ELF_ST_TYPE(x)		(((unsigned int) x) & 0xf)
+#define ELF32_ST_BIND(x)	ELF_ST_BIND(x)
+#define ELF32_ST_TYPE(x)	ELF_ST_TYPE(x)
+#define ELF64_ST_BIND(x)	ELF_ST_BIND(x)
+#define ELF64_ST_TYPE(x)	ELF_ST_TYPE(x)
+
+struct Elf32_Dyn {
+  Elf32_Sword d_tag;
+  union{
+    Elf32_Sword	d_val;
+    Elf32_Addr	d_ptr;
+  } d_un;
+};
+
+struct  Elf64_Dyn {
+  Elf64_Sxword d_tag;		/* entry tag value */
+  union {
+    Elf64_Xword d_val;
+    Elf64_Addr d_ptr;
+  } d_un;
+};
+
+/* The following are used with relocations */
+#define ELF32_R_SYM(x) ((x) >> 8)
+#define ELF32_R_TYPE(x) ((x) & 0xff)
+
+#define ELF64_R_SYM(i)			((i) >> 32)
+#define ELF64_R_TYPE(i)			((i) & 0xffffffff)
+
+struct Elf32_Rel {
+  Elf32_Addr	r_offset;
+  Elf32_Word	r_info;
+};
+
+struct Elf64_Rel {
+  Elf64_Addr r_offset;	/* Location at which to apply the action */
+  Elf64_Xword r_info;	/* index and type of relocation */
+};
+
+struct Elf32_Rela {
+  Elf32_Addr	r_offset;
+  Elf32_Word	r_info;
+  Elf32_Sword	r_addend;
+};
+
+struct Elf64_Rela {
+  Elf64_Addr r_offset;	/* Location at which to apply the action */
+  Elf64_Xword r_info;	/* index and type of relocation */
+  Elf64_Sxword r_addend;	/* Constant addend used to compute value */
+};
+
+struct Elf32_Sym {
+  Elf32_Word	st_name;
+  Elf32_Addr	st_value;
+  Elf32_Word	st_size;
+  unsigned char	st_info;
+  unsigned char	st_other;
+  Elf32_Half	st_shndx;
+};
+
+struct Elf64_Sym {
+  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_Xword st_size;		/* Associated symbol size */
+};
+
+struct Elf32_Ehdr {
+  unsigned char	e_ident[EI_NIDENT];
+  Elf32_Half	e_type;
+  Elf32_Half	e_machine;
+  Elf32_Word	e_version;
+  Elf32_Addr	e_entry;  /* Entry point */
+  Elf32_Off	e_phoff;
+  Elf32_Off	e_shoff;
+  Elf32_Word	e_flags;
+  Elf32_Half	e_ehsize;
+  Elf32_Half	e_phentsize;
+  Elf32_Half	e_phnum;
+  Elf32_Half	e_shentsize;
+  Elf32_Half	e_shnum;
+  Elf32_Half	e_shstrndx;
+};
+
+struct Elf64_Ehdr {
+  unsigned char	e_ident[EI_NIDENT];	/* ELF "magic number" */
+  Elf64_Half e_type;
+  Elf64_Half e_machine;
+  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 */
+  Elf64_Word e_flags;
+  Elf64_Half e_ehsize;
+  Elf64_Half e_phentsize;
+  Elf64_Half e_phnum;
+  Elf64_Half e_shentsize;
+  Elf64_Half e_shnum;
+  Elf64_Half e_shstrndx;
+};
+
+struct Elf32_Phdr {
+  Elf32_Word	p_type;
+  Elf32_Off	p_offset;
+  Elf32_Addr	p_vaddr;
+  Elf32_Addr	p_paddr;
+  Elf32_Word	p_filesz;
+  Elf32_Word	p_memsz;
+  Elf32_Word	p_flags;
+  Elf32_Word	p_align;
+};
+
+struct Elf64_Phdr {
+  Elf64_Word p_type;
+  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_Xword p_filesz;		/* Segment size in file */
+  Elf64_Xword p_memsz;		/* Segment size in memory */
+  Elf64_Xword p_align;		/* Segment alignment, file & memory */
+};
+
+struct Elf32_Shdr {
+  Elf32_Word	sh_name;
+  Elf32_Word	sh_type;
+  Elf32_Word	sh_flags;
+  Elf32_Addr	sh_addr;
+  Elf32_Off	sh_offset;
+  Elf32_Word	sh_size;
+  Elf32_Word	sh_link;
+  Elf32_Word	sh_info;
+  Elf32_Word	sh_addralign;
+  Elf32_Word	sh_entsize;
+};
+
+struct Elf64_Shdr {
+  Elf64_Word sh_name;		/* Section name, index in string tbl */
+  Elf64_Word sh_type;		/* Type of section */
+  Elf64_Xword sh_flags;		/* Miscellaneous section attributes */
+  Elf64_Addr sh_addr;		/* Section virtual addr at execution */
+  Elf64_Off sh_offset;		/* Section file offset */
+  Elf64_Xword sh_size;		/* Size of section in bytes */
+  Elf64_Word sh_link;		/* Index of another section */
+  Elf64_Word sh_info;		/* Additional section information */
+  Elf64_Xword sh_addralign;	/* Section alignment */
+  Elf64_Xword sh_entsize;	/* Entry size if section holds table */
+};
+
+/* Note header in a PT_NOTE section */
+struct Elf32_Nhdr {
+  Elf32_Word	n_namesz;	/* Name size */
+  Elf32_Word	n_descsz;	/* Content size */
+  Elf32_Word	n_type;		/* Content type */
+};
+
+/* Note header in a PT_NOTE section */
+struct Elf64_Nhdr {
+  Elf64_Word n_namesz;	/* Name size */
+  Elf64_Word n_descsz;	/* Content size */
+  Elf64_Word n_type;	/* Content type */
+};
+
+
+#endif	/* _LINUX_ELF_DEFN_H */
===================================================================
--- a/include/linux/elf-em.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef _LINUX_ELF_EM_H
-#define _LINUX_ELF_EM_H
-
-/* These constants define the various ELF target machines */
-#define EM_NONE		0
-#define EM_M32		1
-#define EM_SPARC	2
-#define EM_386		3
-#define EM_68K		4
-#define EM_88K		5
-#define EM_486		6	/* Perhaps disused */
-#define EM_860		7
-#define EM_MIPS		8	/* MIPS R3000 (officially, big-endian only) */
-				/* Next two are historical and binaries and
-				   modules of these types will be rejected by
-				   Linux.  */
-#define EM_MIPS_RS3_LE	10	/* MIPS R3000 little-endian */
-#define EM_MIPS_RS4_BE	10	/* MIPS R4000 big-endian */
-
-#define EM_PARISC	15	/* HPPA */
-#define EM_SPARC32PLUS	18	/* Sun's "v8plus" */
-#define EM_PPC		20	/* PowerPC */
-#define EM_PPC64	21       /* PowerPC64 */
-#define EM_SH		42	/* SuperH */
-#define EM_SPARCV9	43	/* SPARC v9 64-bit */
-#define EM_IA_64	50	/* HP/Intel IA-64 */
-#define EM_X86_64	62	/* AMD x86-64 */
-#define EM_S390		22	/* IBM S/390 */
-#define EM_CRIS		76	/* Axis Communications 32-bit embedded processor */
-#define EM_V850		87	/* NEC v850 */
-#define EM_M32R		88	/* Renesas M32R */
-#define EM_H8_300	46	/* Renesas H8/300,300H,H8S */
-#define EM_BLACKFIN     106     /* ADI Blackfin Processor */
-#define EM_FRV		0x5441	/* Fujitsu FR-V */
-#define EM_AVR32	0x18ad	/* Atmel AVR32 */
-
-/*
- * This is an interim value that we will use until the committee comes
- * up with a final number.
- */
-#define EM_ALPHA	0x9026
-
-/* Bogus old v850 magic number, used by old tools. */
-#define EM_CYGNUS_V850	0x9080
-/* Bogus old m32r magic number, used by old tools. */
-#define EM_CYGNUS_M32R	0x9041
-/* This is the old interim value for S/390 architecture */
-#define EM_S390_OLD	0xA390
-
-
-#endif /* _LINUX_ELF_EM_H */
===================================================================
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -1,12 +1,27 @@
 #ifndef _LINUX_ELF_H
 #define _LINUX_ELF_H
 
-#include <linux/types.h>
-#include <linux/auxvec.h>
-#include <linux/elf-em.h>
+#include <linux/elf-const.h>
+#include <linux/elf-defn.h>
 #include <asm/elf.h>
 
-struct file;
+#if ELF_CLASS == ELFCLASS32
+
+extern Elf32_Dyn _DYNAMIC [];
+#define elfhdr		Elf32_Ehdr
+#define elf_phdr	Elf32_Phdr
+#define elf_note	Elf32_Nhdr
+#define elf_addr_t	Elf32_Off
+
+#else
+
+extern Elf64_Dyn _DYNAMIC [];
+#define elfhdr		Elf64_Ehdr
+#define elf_phdr	Elf64_Phdr
+#define elf_note	Elf64_Nhdr
+#define elf_addr_t	Elf64_Off
+
+#endif
 
 #ifndef elf_read_implies_exec
   /* Executables for which elf_read_implies_exec() returns TRUE will
@@ -15,381 +30,9 @@ struct file;
 # define elf_read_implies_exec(ex, have_pt_gnu_stack)	0
 #endif
 
-/* 32-bit ELF base types. */
-typedef __u32	Elf32_Addr;
-typedef __u16	Elf32_Half;
-typedef __u32	Elf32_Off;
-typedef __s32	Elf32_Sword;
-typedef __u32	Elf32_Word;
+#ifndef ARCH_HAVE_EXTRA_ELF_NOTES
+struct file;
 
-/* 64-bit ELF base types. */
-typedef __u64	Elf64_Addr;
-typedef __u16	Elf64_Half;
-typedef __s16	Elf64_SHalf;
-typedef __u64	Elf64_Off;
-typedef __s32	Elf64_Sword;
-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
-#define PT_LOAD    1
-#define PT_DYNAMIC 2
-#define PT_INTERP  3
-#define PT_NOTE    4
-#define PT_SHLIB   5
-#define PT_PHDR    6
-#define PT_TLS     7               /* Thread local storage segment */
-#define PT_LOOS    0x60000000      /* OS-specific */
-#define PT_HIOS    0x6fffffff      /* OS-specific */
-#define PT_LOPROC  0x70000000
-#define PT_HIPROC  0x7fffffff
-#define PT_GNU_EH_FRAME		0x6474e550
-
-#define PT_GNU_STACK	(PT_LOOS + 0x474e551)
-
-/* These constants define the different elf file types */
-#define ET_NONE   0
-#define ET_REL    1
-#define ET_EXEC   2
-#define ET_DYN    3
-#define ET_CORE   4
-#define ET_LOPROC 0xff00
-#define ET_HIPROC 0xffff
-
-/* This is the info that is needed to parse the dynamic section of the file */
-#define DT_NULL		0
-#define DT_NEEDED	1
-#define DT_PLTRELSZ	2
-#define DT_PLTGOT	3
-#define DT_HASH		4
-#define DT_STRTAB	5
-#define DT_SYMTAB	6
-#define DT_RELA		7
-#define DT_RELASZ	8
-#define DT_RELAENT	9
-#define DT_STRSZ	10
-#define DT_SYMENT	11
-#define DT_INIT		12
-#define DT_FINI		13
-#define DT_SONAME	14
-#define DT_RPATH 	15
-#define DT_SYMBOLIC	16
-#define DT_REL	        17
-#define DT_RELSZ	18
-#define DT_RELENT	19
-#define DT_PLTREL	20
-#define DT_DEBUG	21
-#define DT_TEXTREL	22
-#define DT_JMPREL	23
-#define DT_ENCODING	32
-#define OLD_DT_LOOS	0x60000000
-#define DT_LOOS		0x6000000d
-#define DT_HIOS		0x6ffff000
-#define DT_VALRNGLO	0x6ffffd00
-#define DT_VALRNGHI	0x6ffffdff
-#define DT_ADDRRNGLO	0x6ffffe00
-#define DT_ADDRRNGHI	0x6ffffeff
-#define DT_VERSYM	0x6ffffff0
-#define DT_RELACOUNT	0x6ffffff9
-#define DT_RELCOUNT	0x6ffffffa
-#define DT_FLAGS_1	0x6ffffffb
-#define DT_VERDEF	0x6ffffffc
-#define	DT_VERDEFNUM	0x6ffffffd
-#define DT_VERNEED	0x6ffffffe
-#define	DT_VERNEEDNUM	0x6fffffff
-#define OLD_DT_HIOS     0x6fffffff
-#define DT_LOPROC	0x70000000
-#define DT_HIPROC	0x7fffffff
-
-/* This info is needed when parsing the symbol table */
-#define STB_LOCAL  0
-#define STB_GLOBAL 1
-#define STB_WEAK   2
-
-#define STT_NOTYPE  0
-#define STT_OBJECT  1
-#define STT_FUNC    2
-#define STT_SECTION 3
-#define STT_FILE    4
-#define STT_COMMON  5
-#define STT_TLS     6
-
-#define ELF_ST_BIND(x)		((x) >> 4)
-#define ELF_ST_TYPE(x)		(((unsigned int) x) & 0xf)
-#define ELF32_ST_BIND(x)	ELF_ST_BIND(x)
-#define ELF32_ST_TYPE(x)	ELF_ST_TYPE(x)
-#define ELF64_ST_BIND(x)	ELF_ST_BIND(x)
-#define ELF64_ST_TYPE(x)	ELF_ST_TYPE(x)
-
-typedef struct dynamic{
-  Elf32_Sword d_tag;
-  union{
-    Elf32_Sword	d_val;
-    Elf32_Addr	d_ptr;
-  } d_un;
-} Elf32_Dyn;
-
-typedef struct {
-  Elf64_Sxword d_tag;		/* entry tag value */
-  union {
-    Elf64_Xword d_val;
-    Elf64_Addr d_ptr;
-  } d_un;
-} Elf64_Dyn;
-
-/* The following are used with relocations */
-#define ELF32_R_SYM(x) ((x) >> 8)
-#define ELF32_R_TYPE(x) ((x) & 0xff)
-
-#define ELF64_R_SYM(i)			((i) >> 32)
-#define ELF64_R_TYPE(i)			((i) & 0xffffffff)
-
-typedef struct elf32_rel {
-  Elf32_Addr	r_offset;
-  Elf32_Word	r_info;
-} Elf32_Rel;
-
-typedef struct elf64_rel {
-  Elf64_Addr r_offset;	/* Location at which to apply the action */
-  Elf64_Xword r_info;	/* index and type of relocation */
-} Elf64_Rel;
-
-typedef struct elf32_rela{
-  Elf32_Addr	r_offset;
-  Elf32_Word	r_info;
-  Elf32_Sword	r_addend;
-} Elf32_Rela;
-
-typedef struct elf64_rela {
-  Elf64_Addr r_offset;	/* Location at which to apply the action */
-  Elf64_Xword r_info;	/* index and type of relocation */
-  Elf64_Sxword r_addend;	/* Constant addend used to compute value */
-} Elf64_Rela;
-
-typedef struct elf32_sym{
-  Elf32_Word	st_name;
-  Elf32_Addr	st_value;
-  Elf32_Word	st_size;
-  unsigned char	st_info;
-  unsigned char	st_other;
-  Elf32_Half	st_shndx;
-} Elf32_Sym;
-
-typedef struct elf64_sym {
-  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_Xword st_size;		/* Associated symbol size */
-} Elf64_Sym;
-
-
-#define EI_NIDENT	16
-
-typedef struct elf32_hdr{
-  unsigned char	e_ident[EI_NIDENT];
-  Elf32_Half	e_type;
-  Elf32_Half	e_machine;
-  Elf32_Word	e_version;
-  Elf32_Addr	e_entry;  /* Entry point */
-  Elf32_Off	e_phoff;
-  Elf32_Off	e_shoff;
-  Elf32_Word	e_flags;
-  Elf32_Half	e_ehsize;
-  Elf32_Half	e_phentsize;
-  Elf32_Half	e_phnum;
-  Elf32_Half	e_shentsize;
-  Elf32_Half	e_shnum;
-  Elf32_Half	e_shstrndx;
-} Elf32_Ehdr;
-
-typedef struct elf64_hdr {
-  unsigned char	e_ident[16];		/* ELF "magic number" */
-  Elf64_Half e_type;
-  Elf64_Half e_machine;
-  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 */
-  Elf64_Word e_flags;
-  Elf64_Half e_ehsize;
-  Elf64_Half e_phentsize;
-  Elf64_Half e_phnum;
-  Elf64_Half e_shentsize;
-  Elf64_Half e_shnum;
-  Elf64_Half e_shstrndx;
-} Elf64_Ehdr;
-
-/* These constants define the permissions on sections in the program
-   header, p_flags. */
-#define PF_R		0x4
-#define PF_W		0x2
-#define PF_X		0x1
-
-typedef struct elf32_phdr{
-  Elf32_Word	p_type;
-  Elf32_Off	p_offset;
-  Elf32_Addr	p_vaddr;
-  Elf32_Addr	p_paddr;
-  Elf32_Word	p_filesz;
-  Elf32_Word	p_memsz;
-  Elf32_Word	p_flags;
-  Elf32_Word	p_align;
-} Elf32_Phdr;
-
-typedef struct elf64_phdr {
-  Elf64_Word p_type;
-  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_Xword p_filesz;		/* Segment size in file */
-  Elf64_Xword p_memsz;		/* Segment size in memory */
-  Elf64_Xword p_align;		/* Segment alignment, file & memory */
-} Elf64_Phdr;
-
-/* sh_type */
-#define SHT_NULL	0
-#define SHT_PROGBITS	1
-#define SHT_SYMTAB	2
-#define SHT_STRTAB	3
-#define SHT_RELA	4
-#define SHT_HASH	5
-#define SHT_DYNAMIC	6
-#define SHT_NOTE	7
-#define SHT_NOBITS	8
-#define SHT_REL		9
-#define SHT_SHLIB	10
-#define SHT_DYNSYM	11
-#define SHT_NUM		12
-#define SHT_LOPROC	0x70000000
-#define SHT_HIPROC	0x7fffffff
-#define SHT_LOUSER	0x80000000
-#define SHT_HIUSER	0xffffffff
-
-/* sh_flags */
-#define SHF_WRITE	0x1
-#define SHF_ALLOC	0x2
-#define SHF_EXECINSTR	0x4
-#define SHF_MASKPROC	0xf0000000
-
-/* special section indexes */
-#define SHN_UNDEF	0
-#define SHN_LORESERVE	0xff00
-#define SHN_LOPROC	0xff00
-#define SHN_HIPROC	0xff1f
-#define SHN_ABS		0xfff1
-#define SHN_COMMON	0xfff2
-#define SHN_HIRESERVE	0xffff
- 
-typedef struct {
-  Elf32_Word	sh_name;
-  Elf32_Word	sh_type;
-  Elf32_Word	sh_flags;
-  Elf32_Addr	sh_addr;
-  Elf32_Off	sh_offset;
-  Elf32_Word	sh_size;
-  Elf32_Word	sh_link;
-  Elf32_Word	sh_info;
-  Elf32_Word	sh_addralign;
-  Elf32_Word	sh_entsize;
-} Elf32_Shdr;
-
-typedef struct elf64_shdr {
-  Elf64_Word sh_name;		/* Section name, index in string tbl */
-  Elf64_Word sh_type;		/* Type of section */
-  Elf64_Xword sh_flags;		/* Miscellaneous section attributes */
-  Elf64_Addr sh_addr;		/* Section virtual addr at execution */
-  Elf64_Off sh_offset;		/* Section file offset */
-  Elf64_Xword sh_size;		/* Size of section in bytes */
-  Elf64_Word sh_link;		/* Index of another section */
-  Elf64_Word sh_info;		/* Additional section information */
-  Elf64_Xword sh_addralign;	/* Section alignment */
-  Elf64_Xword sh_entsize;	/* Entry size if section holds table */
-} Elf64_Shdr;
-
-#define	EI_MAG0		0		/* e_ident[] indexes */
-#define	EI_MAG1		1
-#define	EI_MAG2		2
-#define	EI_MAG3		3
-#define	EI_CLASS	4
-#define	EI_DATA		5
-#define	EI_VERSION	6
-#define	EI_OSABI	7
-#define	EI_PAD		8
-
-#define	ELFMAG0		0x7f		/* EI_MAG */
-#define	ELFMAG1		'E'
-#define	ELFMAG2		'L'
-#define	ELFMAG3		'F'
-#define	ELFMAG		"\177ELF"
-#define	SELFMAG		4
-
-#define	ELFCLASSNONE	0		/* EI_CLASS */
-#define	ELFCLASS32	1
-#define	ELFCLASS64	2
-#define	ELFCLASSNUM	3
-
-#define ELFDATANONE	0		/* e_ident[EI_DATA] */
-#define ELFDATA2LSB	1
-#define ELFDATA2MSB	2
-
-#define EV_NONE		0		/* e_version, EI_VERSION */
-#define EV_CURRENT	1
-#define EV_NUM		2
-
-#define ELFOSABI_NONE	0
-#define ELFOSABI_LINUX	3
-
-#ifndef ELF_OSABI
-#define ELF_OSABI ELFOSABI_NONE
-#endif
-
-/* Notes used in ET_CORE */
-#define NT_PRSTATUS	1
-#define NT_PRFPREG	2
-#define NT_PRPSINFO	3
-#define NT_TASKSTRUCT	4
-#define NT_AUXV		6
-#define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */
-
-
-/* Note header in a PT_NOTE section */
-typedef struct elf32_note {
-  Elf32_Word	n_namesz;	/* Name size */
-  Elf32_Word	n_descsz;	/* Content size */
-  Elf32_Word	n_type;		/* Content type */
-} Elf32_Nhdr;
-
-/* Note header in a PT_NOTE section */
-typedef struct elf64_note {
-  Elf64_Word n_namesz;	/* Name size */
-  Elf64_Word n_descsz;	/* Content size */
-  Elf64_Word n_type;	/* Content type */
-} Elf64_Nhdr;
-
-#if ELF_CLASS == ELFCLASS32
-
-extern Elf32_Dyn _DYNAMIC [];
-#define elfhdr		elf32_hdr
-#define elf_phdr	elf32_phdr
-#define elf_note	elf32_note
-#define elf_addr_t	Elf32_Off
-
-#else
-
-extern Elf64_Dyn _DYNAMIC [];
-#define elfhdr		elf64_hdr
-#define elf_phdr	elf64_phdr
-#define elf_note	elf64_note
-#define elf_addr_t	Elf64_Off
-
-#endif
-
-#ifndef ARCH_HAVE_EXTRA_ELF_NOTES
 static inline int arch_notes_size(void) { return 0; }
 static inline void arch_write_notes(struct file *file) { }
 
===================================================================
--- a/include/linux/elfnote.h
+++ b/include/linux/elfnote.h
@@ -58,7 +58,8 @@ 4484:.balign 4				;	\
 	ELFNOTE_END
 
 #else	/* !__ASSEMBLER__ */
-#include <linux/elf.h>
+#include <linux/elf-defn.h>
+#include <asm/elf-defines.h>
 /*
  * Use an anonymous structure which matches the shape of
  * Elf{32,64}_Nhdr, but includes the name and desc data.  The size and
@@ -67,15 +68,15 @@ 4484:.balign 4				;	\
  * only define one note per line, since __LINE__ is used to generate
  * unique symbols.
  */
-#define _ELFNOTE_PASTE(a,b)	a##b
-#define _ELFNOTE(size, name, unique, type, desc)			\
+#define __ELFNOTE_PASTE(a,b)	a##b
+#define __ELFNOTE(size, name, unique, type, desc)			\
 	static const struct {						\
-		struct elf##size##_note _nhdr;				\
+		struct Elf##size##_Nhdr _nhdr;				\
 		unsigned char _name[sizeof(name)]			\
-		__attribute__((aligned(sizeof(Elf##size##_Word))));	\
+			__attribute__((aligned(sizeof(Elf##size##_Word)))); \
 		typeof(desc) _desc					\
-			     __attribute__((aligned(sizeof(Elf##size##_Word)))); \
-	} _ELFNOTE_PASTE(_note_, unique)				\
+			__attribute__((aligned(sizeof(Elf##size##_Word)))); \
+	} __ELFNOTE_PASTE(_note_, unique)				\
 		__attribute_used__					\
 		__attribute__((section(".note." name),			\
 			       aligned(sizeof(Elf##size##_Word)),	\
@@ -88,11 +89,18 @@ 4484:.balign 4				;	\
 		name,							\
 		desc							\
 	}
-#define ELFNOTE(size, name, type, desc)		\
-	_ELFNOTE(size, name, __LINE__, type, desc)
 
-#define ELFNOTE32(name, type, desc) ELFNOTE(32, name, type, desc)
-#define ELFNOTE64(name, type, desc) ELFNOTE(64, name, type, desc)
+#define ELFNOTE32(name, type, desc) __ELFNOTE(32, name, __LINE__, type, desc)
+#define ELFNOTE64(name, type, desc) __ELFNOTE(64, name, __LINE__, type, desc)
+
+#if ELF_CLASS == ELFCLASS32
+#define ELFNOTE(name, type, desc)	ELFNOTE32(name, type, desc)
+#elif ELF_CLASS == ELFCLASS64
+#define ELFNOTE(name, type, desc)	ELFNOTE64(name, type, desc)
+#else
+#error Define ELFNOTE for this ELF_CLASS
+#endif
+
 #endif	/* __ASSEMBLER__ */
 
 #endif /* _LINUX_ELFNOTE_H */
===================================================================
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -11,7 +11,6 @@
 #include <linux/compiler.h>
 #include <linux/cache.h>
 #include <linux/kmod.h>
-#include <linux/elf.h>
 #include <linux/stringify.h>
 #include <linux/kobject.h>
 #include <linux/moduleparam.h>
===================================================================
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -50,6 +50,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
+#include <asm/elf.h>
 
 extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
                      void __user *buffer, size_t *lenp, loff_t *ppos);
===================================================================
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -38,6 +38,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/bug.h>
+#include <linux/elf.h>
 
 extern const struct bug_entry __start___bug_table[], __stop___bug_table[];
 

-- 


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
@ 2007-06-21  8:20   ` ian
  2007-06-21 15:06     ` Jeremy Fitzhardinge
  2007-06-21 16:49   ` Chris Zankel
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: ian @ 2007-06-21  8:20 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Russell King, Haavard Skinnemoen, Aubrey Li,
	Mikael Starvik, David Howells, Yoshinori Sato, Andi Kleen,
	Tony Luck, Geert Uytterhoeven, Ralf Baechle, Matthew Wilcox,
	Paul Mackerras, Martin Schwidefsky, Paul Mundt, David S. Miller,
	Miles Bader, Chris Zankel

On Wed, 2007-06-20 at 16:08 -0700, Jeremy Fitzhardinge wrote:

arm26 changes acked-by: Ian Molton <spyro@f2s.com>


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-21  8:20   ` ian
@ 2007-06-21 15:06     ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-21 15:06 UTC (permalink / raw)
  To: ian
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Russell King, Haavard Skinnemoen, Aubrey Li,
	Mikael Starvik, David Howells, Yoshinori Sato, Andi Kleen,
	Tony Luck, Geert Uytterhoeven, Ralf Baechle, Matthew Wilcox,
	Paul Mackerras, Martin Schwidefsky, Paul Mundt, David S. Miller,
	Miles Bader, Chris Zankel

ian wrote:
> On Wed, 2007-06-20 at 16:08 -0700, Jeremy Fitzhardinge wrote:
>
> arm26 changes acked-by: Ian Molton <spyro@f2s.com>

Did you try building it to flush out any missing-header problems?

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
  2007-06-21  8:20   ` ian
@ 2007-06-21 16:49   ` Chris Zankel
  2007-06-21 18:31     ` Jeremy Fitzhardinge
  2007-06-25  9:02   ` David Woodhouse
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Chris Zankel @ 2007-06-21 16:49 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Paul Mackerras, Martin Schwidefsky, Paul Mundt,
	David S. Miller, Miles Bader

Jeremy,

Could you please add the ELF architecture-magic number for Xtensa (94) 
when you finally submit this patch?

Jeremy Fitzhardinge wrote:
> This patch cleans up the ELF headers and their users.  It does several
> related things:
> --- /dev/null
> +++ b/include/linux/elf-const.h
> @@ -0,0 +1,222 @@
> +#ifndef _LINUX_ELF_CONST_H
> +#define _LINUX_ELF_CONST_H
> +
> +/* These constants define the various ELF target machines */
> +#define EM_NONE		0
...
> +#define EM_V850		87	/* NEC v850 */
> +#define EM_M32R		88	/* Renesas M32R */

#define EM_XTENSA       94

Thanks,
-Chris

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-21 16:49   ` Chris Zankel
@ 2007-06-21 18:31     ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-21 18:31 UTC (permalink / raw)
  To: Chris Zankel
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Paul Mackerras, Martin Schwidefsky, Paul Mundt,
	David S. Miller, Miles Bader

Chris Zankel wrote:
> Jeremy,
>
> Could you please add the ELF architecture-magic number for Xtensa (94) 
> when you finally submit this patch?

I guess, but I think it would be better if you just sent an incremental 
patch to add it.  Does my patch work OK for Xtensa?

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
  2007-06-21  8:20   ` ian
  2007-06-21 16:49   ` Chris Zankel
@ 2007-06-25  9:02   ` David Woodhouse
  2007-06-25 12:43     ` Jeremy Fitzhardinge
  2007-06-25 13:40     ` Roman Zippel
  2007-06-25 13:37   ` Roman Zippel
                     ` (3 subsequent siblings)
  6 siblings, 2 replies; 24+ messages in thread
From: David Woodhouse @ 2007-06-25  9:02 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Paul Mackerras, Martin Schwidefsky, Paul Mundt,
	David S. Miller, Miles Bader, Chris Zankel

On Wed, 2007-06-20 at 16:08 -0700, Jeremy Fitzhardinge wrote:
> This patch cleans up the ELF headers and their users.  It does several
> related things:

Looks good. We can get away with exporting a lot less of this to
userspace too, can't we?

-- 
dwmw2


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-25  9:02   ` David Woodhouse
@ 2007-06-25 12:43     ` Jeremy Fitzhardinge
  2007-06-25 13:40     ` Roman Zippel
  1 sibling, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-25 12:43 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Paul Mackerras, Martin Schwidefsky, Paul Mundt,
	David S. Miller, Miles Bader, Chris Zankel

David Woodhouse wrote:
> On Wed, 2007-06-20 at 16:08 -0700, Jeremy Fitzhardinge wrote:
>   
>> This patch cleans up the ELF headers and their users.  It does several
>> related things:
>>     
>
> Looks good. We can get away with exporting a lot less of this to
> userspace too, can't we?
>   

Probably.  What needs to be exported at all?

    J


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
                     ` (2 preceding siblings ...)
  2007-06-25  9:02   ` David Woodhouse
@ 2007-06-25 13:37   ` Roman Zippel
  2007-06-26 19:29     ` Jeremy Fitzhardinge
  2007-06-25 15:18   ` Roman Zippel
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Roman Zippel @ 2007-06-25 13:37 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch

Hi,

On Wed, 20 Jun 2007, Jeremy Fitzhardinge wrote:

> This patch cleans up the ELF headers and their users.  It does several
> related things:
> 
> 1. split linux/elf.h into pieces
> 
> This splits linux/elf.h into several pieces:
> 	linux/elf.h		- still the common elf header,
> 				  functionally unchanged
> 	linux/elf-const.h	- ELF constants, includable by asm code

We have the __ASSEMBLY__ define for this, so just for asm code we don't 
need a separate header.

> 	linux/elf-decl.h	- ELF type declarations, without definitions
> 	linux/elf-defn.h	- ELF type definitions

What's the point in splitting these two?

After this patch <linux/elf.h> seems to be pretty much empty, I'd rather 
suggest to move the function declarations to elfcore.h and leave the basic 
elf definitions in elf.h. Many small header files have the disadvantage 
that it takes longer to find the needed information.

bye, Roman

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-25  9:02   ` David Woodhouse
  2007-06-25 12:43     ` Jeremy Fitzhardinge
@ 2007-06-25 13:40     ` Roman Zippel
  2007-06-25 13:56       ` Clemens Koller
  1 sibling, 1 reply; 24+ messages in thread
From: Roman Zippel @ 2007-06-25 13:40 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Jeremy Fitzhardinge, Eric W. Biederman, lkml, Andrew Morton, Linux Arch

Hi,

On Mon, 25 Jun 2007, David Woodhouse wrote:

> On Wed, 2007-06-20 at 16:08 -0700, Jeremy Fitzhardinge wrote:
> > This patch cleans up the ELF headers and their users.  It does several
> > related things:
> 
> Looks good. We can get away with exporting a lot less of this to
> userspace too, can't we?

glibc provides its own version, so it doesn't has to be exported at all.

bye, Roman

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-25 13:40     ` Roman Zippel
@ 2007-06-25 13:56       ` Clemens Koller
  2007-06-25 14:06         ` Roman Zippel
  0 siblings, 1 reply; 24+ messages in thread
From: Clemens Koller @ 2007-06-25 13:56 UTC (permalink / raw)
  To: Roman Zippel
  Cc: David Woodhouse, Jeremy Fitzhardinge, Eric W. Biederman, lkml,
	Andrew Morton, Linux Arch

Hi, Roman!

Roman Zippel schrieb:
> Hi,
> 
> On Mon, 25 Jun 2007, David Woodhouse wrote:
> 
>> On Wed, 2007-06-20 at 16:08 -0700, Jeremy Fitzhardinge wrote:
>>> This patch cleans up the ELF headers and their users.  It does several
>>> related things:
>> Looks good. We can get away with exporting a lot less of this to
>> userspace too, can't we?
> 
> glibc provides its own version, so it doesn't has to be exported at all.

AFAIK the glibc folks want to rely more on the linux kernel headers
in the future and not provide more or less redundant headers anymore...
Please talk to them about the future plans.

Regards,
-- 
Clemens Koller
__________________________________
R&D Imaging Devices
Anagramm GmbH
Rupert-Mayer-Straße 45/1
Linhof Werksgelände
D-81379 München
Tel.089-741518-50
Fax 089-741518-19
http://www.anagramm-technology.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-25 13:56       ` Clemens Koller
@ 2007-06-25 14:06         ` Roman Zippel
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Zippel @ 2007-06-25 14:06 UTC (permalink / raw)
  To: Clemens Koller
  Cc: David Woodhouse, Jeremy Fitzhardinge, Eric W. Biederman, lkml,
	Andrew Morton, Linux Arch

Hi,

On Mon, 25 Jun 2007, Clemens Koller wrote:

> > glibc provides its own version, so it doesn't has to be exported at all.
> 
> AFAIK the glibc folks want to rely more on the linux kernel headers
> in the future and not provide more or less redundant headers anymore...

In this case it's more an ABI header, it doesn't export any kernel 
interfaces.

bye, Roman

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
                     ` (3 preceding siblings ...)
  2007-06-25 13:37   ` Roman Zippel
@ 2007-06-25 15:18   ` Roman Zippel
  2007-06-26 19:28     ` Jeremy Fitzhardinge
  2007-06-29  4:13   ` Paul Mackerras
  2007-06-29  4:48   ` Paul Mackerras
  6 siblings, 1 reply; 24+ messages in thread
From: Roman Zippel @ 2007-06-25 15:18 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch

Hi,

On Wed, 20 Jun 2007, Jeremy Fitzhardinge wrote:

> 	linux/elf-const.h	- ELF constants, includable by asm code

BTW who's the maniac who tries to use this in asm code?
Many of these constants are pretty useless without the corresponding 
structure definitions.

bye, Roman

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-25 15:18   ` Roman Zippel
@ 2007-06-26 19:28     ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-26 19:28 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch

Roman Zippel wrote:
>> 	linux/elf-const.h	- ELF constants, includable by asm code
>>     
>
> BTW who's the maniac who tries to use this in asm code?
> Many of these constants are pretty useless without the corresponding 
> structure definitions.

I was for a while, in order to hand-craft ELF headers for the bzImage 
boot image, but I since changed it to define these structures from C.  
Still, its useful to have the constants separate, since they are used 
separate from their corresponding structures.

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-25 13:37   ` Roman Zippel
@ 2007-06-26 19:29     ` Jeremy Fitzhardinge
  2007-06-27 23:25       ` Roman Zippel
  0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-26 19:29 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch, Al Viro

Roman Zippel wrote:
>> This patch cleans up the ELF headers and their users.  It does several
>> related things:
>>
>> 1. split linux/elf.h into pieces
>>
>> This splits linux/elf.h into several pieces:
>> 	linux/elf.h		- still the common elf header,
>> 				  functionally unchanged
>> 	linux/elf-const.h	- ELF constants, includable by asm code
>>     
>
> We have the __ASSEMBLY__ define for this, so just for asm code we don't 
> need a separate header.
>   

Hm.  The number of __ASSEMBLY__s end up being pretty large, and it just 
seemed cleaner to put them in separate headers.

>> 	linux/elf-decl.h	- ELF type declarations, without definitions
>> 	linux/elf-defn.h	- ELF type definitions
>>     
>
> What's the point in splitting these two?
>   

Because there are other headers which just need some type 
forward-declarations, and don't need the whole set of ELF types 
defined.  In particular, linux/module.h - which is included all over the 
place in the kernel - needs a couple of ELF types declared, and 
including it all over the place is just a waste.  Also, there were some 
nasty cyclic header dependency problems around linux/elf.h, 
linux/module.h, linux/bug.h and asm/bug.h which ended up leading to some 
awkward hacks; I need to remind myself what the problems were and see if 
this elf cleanup helps (pretty sure it should).

> After this patch <linux/elf.h> seems to be pretty much empty, I'd rather 
> suggest to move the function declarations to elfcore.h and leave the basic 
> elf definitions in elf.h. Many small header files have the disadvantage 
> that it takes longer to find the needed information.
>   
linux/elf.h ends up pulling in a really surprising amount of stuff, 
mostly because it ends up including asm/elf.h.  asm/elf.h, in turn, 
depending on the architecture, pulls in a wide variety of other 
headers.  When I cleaned this up, I found quite a few buggy .c files 
which ended up relying on implicit includes via this chain.

Given that there's been a general push to try and cut down on the number 
of header dependency entanglements, I thought I could contribute while 
solving my own immediate problems.

linux/elfcore.h is specifically related to ELF core files, so the two 
corefile notes-related headers could be moved there.

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-26 19:29     ` Jeremy Fitzhardinge
@ 2007-06-27 23:25       ` Roman Zippel
  2007-06-28 15:45         ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 24+ messages in thread
From: Roman Zippel @ 2007-06-27 23:25 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch, Al Viro

Hi,

On Tue, 26 Jun 2007, Jeremy Fitzhardinge wrote:

> > We have the __ASSEMBLY__ define for this, so just for asm code we don't need
> > a separate header.
> >   
> 
> Hm.  The number of __ASSEMBLY__s end up being pretty large, and it just seemed
> cleaner to put them in separate headers.

This could be avoided by reordering things within elf.h, but is it really 
necessary since there is no user of this right now?
Having actual users would help to decide how to deal with this, since e.g. 
if only a few constants were needed this could also be done via 
asm-offsets.h.

> > > 	linux/elf-decl.h	- ELF type declarations, without definitions
> > > 	linux/elf-defn.h	- ELF type definitions
> > >     
> > 
> > What's the point in splitting these two?
> >   
> 
> Because there are other headers which just need some type
> forward-declarations, and don't need the whole set of ELF types defined.  In
> particular, linux/module.h - which is included all over the place in the
> kernel - needs a couple of ELF types declared, and including it all over the
> place is just a waste.

module.h does indeed pull in way too much, but instead of hacking headers 
into little pieces, IMO it would be better to solve the real problem.
I played with it a little and the patch below moves a lot stuff out of 
module.h, so this would drastically reduce the header dependencies.
Unless there are major objections, I can test the patch a little more and 
convert the other archs.

bye, Roman

---
 arch/i386/kernel/module.c    |   24 +--
 drivers/base/bus.c           |    4 
 include/linux/module.h       |  173 ---------------------------
 include/linux/moduleloader.h |  212 +++++++++++++++++++++++++++++++++-
 include/linux/moduleparam.h  |   22 ---
 include/linux/unwind.h       |    4 
 kernel/module.c              |  267 +++++++++++++++++++++----------------------
 kernel/params.c              |   13 +-
 scripts/mod/modpost.c        |    9 -
 9 files changed, 369 insertions(+), 359 deletions(-)

Index: linux-2.6/include/linux/module.h
===================================================================
--- linux-2.6.orig/include/linux/module.h
+++ linux-2.6/include/linux/module.h
@@ -44,23 +44,6 @@ struct modversion_info
 
 struct module;
 
-struct module_attribute {
-        struct attribute attr;
-        ssize_t (*show)(struct module_attribute *, struct module *, char *);
-        ssize_t (*store)(struct module_attribute *, struct module *,
-			 const char *, size_t count);
-	void (*setup)(struct module *, const char *);
-	int (*test)(struct module *);
-	void (*free)(struct module *);
-};
-
-struct module_kobject
-{
-	struct kobject kobj;
-	struct module *mod;
-	struct kobject *drivers_dir;
-};
-
 /* These are either module local, or the kernel's dummy ones. */
 extern int init_module(void);
 extern void cleanup_module(void);
@@ -229,95 +212,13 @@ enum module_state
 	MODULE_STATE_GOING,
 };
 
-/* Similar stuff for section attributes. */
-struct module_sect_attr
-{
-	struct module_attribute mattr;
-	char *name;
-	unsigned long address;
-};
-
-struct module_sect_attrs
-{
-	struct attribute_group grp;
-	int nsections;
-	struct module_sect_attr attrs[0];
-};
-
-struct module_param_attrs;
-
 struct module
 {
 	enum module_state state;
 
-	/* Member of list of modules */
-	struct list_head list;
-
 	/* Unique handle for this module */
 	char name[MODULE_NAME_LEN];
 
-	/* Sysfs stuff. */
-	struct module_kobject mkobj;
-	struct module_param_attrs *param_attrs;
-	struct module_attribute *modinfo_attrs;
-	const char *version;
-	const char *srcversion;
-	struct kobject *holders_dir;
-
-	/* Exported symbols */
-	const struct kernel_symbol *syms;
-	unsigned int num_syms;
-	const unsigned long *crcs;
-
-	/* GPL-only exported symbols. */
-	const struct kernel_symbol *gpl_syms;
-	unsigned int num_gpl_syms;
-	const unsigned long *gpl_crcs;
-
-	/* unused exported symbols. */
-	const struct kernel_symbol *unused_syms;
-	unsigned int num_unused_syms;
-	const unsigned long *unused_crcs;
-	/* GPL-only, unused exported symbols. */
-	const struct kernel_symbol *unused_gpl_syms;
-	unsigned int num_unused_gpl_syms;
-	const unsigned long *unused_gpl_crcs;
-
-	/* symbols that will be GPL-only in the near future. */
-	const struct kernel_symbol *gpl_future_syms;
-	unsigned int num_gpl_future_syms;
-	const unsigned long *gpl_future_crcs;
-
-	/* Exception table */
-	unsigned int num_exentries;
-	const struct exception_table_entry *extable;
-
-	/* Startup function. */
-	int (*init)(void);
-
-	/* If this is non-NULL, vfree after init() returns */
-	void *module_init;
-
-	/* Here is the actual code + data, vfree'd on unload. */
-	void *module_core;
-
-	/* Here are the sizes of the init and core sections */
-	unsigned long init_size, core_size;
-
-	/* The size of the executable code in each section.  */
-	unsigned long init_text_size, core_text_size;
-
-	/* The handle returned from unwind_add_table. */
-	void *unwind_info;
-
-	/* Arch-specific module values */
-	struct mod_arch_specific arch;
-
-	/* Am I unsafe to unload? */
-	int unsafe;
-
-	unsigned int taints;	/* same bits as kernel:tainted */
-
 #ifdef CONFIG_GENERIC_BUG
 	/* Support for BUG */
 	struct list_head bug_list;
@@ -328,25 +229,6 @@ struct module
 #ifdef CONFIG_MODULE_UNLOAD
 	/* Reference counts */
 	struct module_ref ref[NR_CPUS];
-
-	/* What modules depend on me? */
-	struct list_head modules_which_use_me;
-
-	/* Who is waiting for us to be unloaded */
-	struct task_struct *waiter;
-
-	/* Destruction function. */
-	void (*exit)(void);
-#endif
-
-#ifdef CONFIG_KALLSYMS
-	/* We keep the symbol and string tables for kallsyms. */
-	Elf_Sym *symtab;
-	unsigned long num_symtab;
-	char *strtab;
-
-	/* Section attributes */
-	struct module_sect_attrs *sect_attrs;
 #endif
 
 	/* Per-cpu data. */
@@ -356,9 +238,6 @@ struct module
 	   keeping pointers to this stuff */
 	char *args;
 };
-#ifndef MODULE_ARCH_INIT
-#define MODULE_ARCH_INIT {}
-#endif
 
 /* FIXME: It'd be nice to isolate modules during init, too, so they
    aren't used before they (may) fail.  But presently too much code
@@ -571,58 +450,6 @@ static inline void print_modules(void)
 
 #endif /* CONFIG_MODULES */
 
-struct device_driver;
-#ifdef CONFIG_SYSFS
-struct module;
-
-extern struct kset module_subsys;
-
-int mod_sysfs_init(struct module *mod);
-int mod_sysfs_setup(struct module *mod,
-			   struct kernel_param *kparam,
-			   unsigned int num_params);
-int module_add_modinfo_attrs(struct module *mod);
-void module_remove_modinfo_attrs(struct module *mod);
-
-#else /* !CONFIG_SYSFS */
-
-static inline int mod_sysfs_init(struct module *mod)
-{
-	return 0;
-}
-
-static inline int mod_sysfs_setup(struct module *mod,
-			   struct kernel_param *kparam,
-			   unsigned int num_params)
-{
-	return 0;
-}
-
-static inline int module_add_modinfo_attrs(struct module *mod)
-{
-	return 0;
-}
-
-static inline void module_remove_modinfo_attrs(struct module *mod)
-{ }
-
-#endif /* CONFIG_SYSFS */
-
-#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
-
-void module_add_driver(struct module *mod, struct device_driver *drv);
-void module_remove_driver(struct device_driver *drv);
-
-#else /* not both CONFIG_SYSFS && CONFIG_MODULES */
-
-static inline void module_add_driver(struct module *mod, struct device_driver *drv)
-{ }
-
-static inline void module_remove_driver(struct device_driver *drv)
-{ }
-
-#endif
-
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
 
 /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
Index: linux-2.6/include/linux/moduleloader.h
===================================================================
--- linux-2.6.orig/include/linux/moduleloader.h
+++ linux-2.6/include/linux/moduleloader.h
@@ -5,20 +5,148 @@
 #include <linux/module.h>
 #include <linux/elf.h>
 
+struct module_kobject
+{
+	struct kobject kobj;
+	struct module_private *mod;
+	struct kobject *drivers_dir;
+};
+
+#define get_mod_private(m)	container_of(m, struct module_private, mod)
+
+struct module_private
+{
+	struct module mod;
+
+	/* Member of list of modules */
+	struct list_head list;
+
+	/* Sysfs stuff. */
+	struct module_kobject mkobj;
+	struct module_param_attrs *param_attrs;
+	struct module_attribute *modinfo_attrs;
+	const char *version;
+	const char *srcversion;
+	struct kobject *holders_dir;
+
+	/* Exported symbols */
+	const struct kernel_symbol *syms;
+	unsigned int num_syms;
+	const unsigned long *crcs;
+
+	/* GPL-only exported symbols. */
+	const struct kernel_symbol *gpl_syms;
+	unsigned int num_gpl_syms;
+	const unsigned long *gpl_crcs;
+
+	/* unused exported symbols. */
+	const struct kernel_symbol *unused_syms;
+	unsigned int num_unused_syms;
+	const unsigned long *unused_crcs;
+	/* GPL-only, unused exported symbols. */
+	const struct kernel_symbol *unused_gpl_syms;
+	unsigned int num_unused_gpl_syms;
+	const unsigned long *unused_gpl_crcs;
+
+	/* symbols that will be GPL-only in the near future. */
+	const struct kernel_symbol *gpl_future_syms;
+	unsigned int num_gpl_future_syms;
+	const unsigned long *gpl_future_crcs;
+
+	/* Exception table */
+	unsigned int num_exentries;
+	const struct exception_table_entry *extable;
+
+	/* Startup function. */
+	int (*init)(void);
+
+	/* If this is non-NULL, vfree after init() returns */
+	void *module_init;
+
+	/* Here is the actual code + data, vfree'd on unload. */
+	void *module_core;
+
+	/* Here are the sizes of the init and core sections */
+	unsigned long init_size, core_size;
+
+	/* The size of the executable code in each section.  */
+	unsigned long init_text_size, core_text_size;
+
+	/* The handle returned from unwind_add_table. */
+	void *unwind_info;
+
+	/* Arch-specific module values */
+	struct mod_arch_specific arch;
+
+	/* Am I unsafe to unload? */
+	int unsafe;
+
+	unsigned int taints;	/* same bits as kernel:tainted */
+
+#ifdef CONFIG_MODULE_UNLOAD
+	/* What modules depend on me? */
+	struct list_head modules_which_use_me;
+
+	/* Who is waiting for us to be unloaded */
+	struct task_struct *waiter;
+
+	/* Destruction function. */
+	void (*exit)(void);
+#endif
+
+#ifdef CONFIG_KALLSYMS
+	/* We keep the symbol and string tables for kallsyms. */
+	Elf_Sym *symtab;
+	unsigned long num_symtab;
+	char *strtab;
+
+	/* Section attributes */
+	struct module_sect_attrs *sect_attrs;
+#endif
+};
+#ifndef MODULE_ARCH_INIT
+#define MODULE_ARCH_INIT {}
+#endif
+
+struct module_attribute {
+        struct attribute attr;
+        ssize_t (*show)(struct module_attribute *, struct module_private *, char *);
+        ssize_t (*store)(struct module_attribute *, struct module_private *,
+			 const char *, size_t count);
+	void (*setup)(struct module_private *, const char *);
+	int (*test)(struct module_private *);
+	void (*free)(struct module_private *);
+};
+
+/* Similar stuff for section attributes. */
+struct module_sect_attr
+{
+	struct module_attribute mattr;
+	char *name;
+	unsigned long address;
+};
+
+struct module_sect_attrs
+{
+	struct attribute_group grp;
+	int nsections;
+	struct module_sect_attr attrs[0];
+};
+
 /* These must be implemented by the specific architecture */
 
 /* Adjust arch-specific sections.  Return 0 on success.  */
 int module_frob_arch_sections(Elf_Ehdr *hdr,
 			      Elf_Shdr *sechdrs,
 			      char *secstrings,
-			      struct module *mod);
+			      struct module_private *mod);
 
 /* Allocator used for allocating struct module, core sections and init
    sections.  Returns NULL on failure. */
 void *module_alloc(unsigned long size);
 
 /* Free memory returned from module_alloc. */
-void module_free(struct module *mod, void *module_region);
+void module_free(struct module_private *mod, void *module_region);
 
 /* Apply the given relocation to the (simplified) ELF.  Return -error
    or 0. */
@@ -26,7 +154,7 @@ int apply_relocate(Elf_Shdr *sechdrs,
 		   const char *strtab,
 		   unsigned int symindex,
 		   unsigned int relsec,
-		   struct module *mod);
+		   struct module_private *mod);
 
 /* Apply the given add relocation to the (simplified) ELF.  Return
    -error or 0 */
@@ -34,14 +162,86 @@ int apply_relocate_add(Elf_Shdr *sechdrs
 		       const char *strtab,
 		       unsigned int symindex,
 		       unsigned int relsec,
-		       struct module *mod);
+		       struct module_private *mod);
 
 /* Any final processing of module before access.  Return -error or 0. */
 int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
-		    struct module *mod);
+		    struct module_private *mod);
 
 /* Any cleanup needed when module leaves. */
-void module_arch_cleanup(struct module *mod);
+void module_arch_cleanup(struct module_private *mod);
+
+/* for exporting parameters in /sys/parameters */
+
+struct device_driver;
+
+#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
+extern int module_param_sysfs_setup(struct module_private *mod,
+				    struct kernel_param *kparam,
+				    unsigned int num_params);
+
+extern void module_param_sysfs_remove(struct module_private *mod);
+
+void module_add_driver(struct module_private *mod, struct device_driver *drv);
+void module_remove_driver(struct device_driver *drv);
+
+#else
+static inline int module_param_sysfs_setup(struct module_private *mod,
+					   struct kernel_param *kparam,
+					   unsigned int num_params)
+{
+	return 0;
+}
+
+static inline void module_param_sysfs_remove(struct module_private *mod)
+{
+}
+
+static inline void module_add_driver(struct module_private *mod, struct device_driver *drv)
+{
+}
+
+static inline void module_remove_driver(struct device_driver *drv)
+{
+}
+
+#endif
+
+#ifdef CONFIG_SYSFS
+
+extern struct kset module_subsys;
+
+int mod_sysfs_init(struct module_private *mod);
+int mod_sysfs_setup(struct module_private *mod,
+			   struct kernel_param *kparam,
+			   unsigned int num_params);
+int module_add_modinfo_attrs(struct module_private *mod);
+void module_remove_modinfo_attrs(struct module_private *mod);
+
+#else /* !CONFIG_SYSFS */
+
+static inline int mod_sysfs_init(struct module *mod)
+{
+	return 0;
+}
+
+static inline int mod_sysfs_setup(struct module_private *mod,
+			   struct kernel_param *kparam,
+			   unsigned int num_params)
+{
+	return 0;
+}
+
+static inline int module_add_modinfo_attrs(struct module_private *mod)
+{
+	return 0;
+}
+
+static inline void module_remove_modinfo_attrs(struct module_private *mod)
+{
+}
+
+#endif /* CONFIG_SYSFS */
 
 #endif
Index: linux-2.6/include/linux/moduleparam.h
===================================================================
--- linux-2.6.orig/include/linux/moduleparam.h
+++ linux-2.6/include/linux/moduleparam.h
@@ -165,26 +165,4 @@ extern int param_array_get(char *buffer,
 extern int param_set_copystring(const char *val, struct kernel_param *kp);
 extern int param_get_string(char *buffer, struct kernel_param *kp);
 
-/* for exporting parameters in /sys/parameters */
-
-struct module;
-
-#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
-extern int module_param_sysfs_setup(struct module *mod,
-				    struct kernel_param *kparam,
-				    unsigned int num_params);
-
-extern void module_param_sysfs_remove(struct module *mod);
-#else
-static inline int module_param_sysfs_setup(struct module *mod,
-			     struct kernel_param *kparam,
-			     unsigned int num_params)
-{
-	return 0;
-}
-
-static inline void module_param_sysfs_remove(struct module *mod)
-{ }
-#endif
-
 #endif /* _LINUX_MODULE_PARAMS_H */
Index: linux-2.6/include/linux/unwind.h
===================================================================
--- linux-2.6.orig/include/linux/unwind.h
+++ linux-2.6/include/linux/unwind.h
@@ -12,7 +12,7 @@
  * is not much point in implementing the full Dwarf2 unwind API.
  */
 
-struct module;
+struct module_private;
 
 struct unwind_frame_info {};
 
@@ -21,7 +21,7 @@ static inline void unwind_setup(void) {}
 
 #ifdef CONFIG_MODULES
 
-static inline void *unwind_add_table(struct module *mod,
+static inline void *unwind_add_table(struct module_private *mod,
                                      const void *table_start,
                                      unsigned long table_size)
 {
Index: linux-2.6/kernel/module.c
===================================================================
--- linux-2.6.orig/kernel/module.c
+++ linux-2.6/kernel/module.c
@@ -90,7 +90,7 @@ static inline int strong_try_module_get(
 	return try_module_get(mod);
 }
 
-static inline void add_taint_module(struct module *mod, unsigned flag)
+static inline void add_taint_module(struct module_private *mod, unsigned flag)
 {
 	add_taint(flag);
 	mod->taints |= flag;
@@ -173,11 +173,11 @@ static void printk_unused_warning(const 
 
 /* Find a symbol, return value, crc and module which owns it */
 static unsigned long __find_symbol(const char *name,
-				   struct module **owner,
+				   struct module_private **owner,
 				   const unsigned long **crc,
 				   int gplok)
 {
-	struct module *mod;
+	struct module_private *mod;
 	const struct kernel_symbol *ks;
 
 	/* Core kernel first. */ 
@@ -290,12 +290,12 @@ static unsigned long __find_symbol(const
 }
 
 /* Search for module by name: must hold module_mutex. */
-static struct module *find_module(const char *name)
+static struct module_private *find_module(const char *name)
 {
-	struct module *mod;
+	struct module_private *mod;
 
 	list_for_each_entry(mod, &modules, list) {
-		if (strcmp(mod->name, name) == 0)
+		if (strcmp(mod->mod.name, name) == 0)
 			return mod;
 	}
 	return NULL;
@@ -469,20 +469,20 @@ static inline void percpu_modcopy(void *
 #endif /* CONFIG_SMP */
 
 #define MODINFO_ATTR(field)	\
-static void setup_modinfo_##field(struct module *mod, const char *s)  \
+static void setup_modinfo_##field(struct module_private *mod, const char *s) \
 {                                                                     \
 	mod->field = kstrdup(s, GFP_KERNEL);                          \
 }                                                                     \
 static ssize_t show_modinfo_##field(struct module_attribute *mattr,   \
-	                struct module *mod, char *buffer)             \
+	                struct module_private *mod, char *buffer)     \
 {                                                                     \
 	return sprintf(buffer, "%s\n", mod->field);                   \
 }                                                                     \
-static int modinfo_##field##_exists(struct module *mod)               \
+static int modinfo_##field##_exists(struct module_private *mod)       \
 {                                                                     \
 	return mod->field != NULL;                                    \
 }                                                                     \
-static void free_modinfo_##field(struct module *mod)                  \
+static void free_modinfo_##field(struct module_private *mod)          \
 {                                                                     \
         kfree(mod->field);                                            \
         mod->field = NULL;                                            \
@@ -501,15 +501,15 @@ MODINFO_ATTR(srcversion);
 
 #ifdef CONFIG_MODULE_UNLOAD
 /* Init the unload section of the module. */
-static void module_unload_init(struct module *mod)
+static void module_unload_init(struct module_private *mod)
 {
 	unsigned int i;
 
 	INIT_LIST_HEAD(&mod->modules_which_use_me);
 	for (i = 0; i < NR_CPUS; i++)
-		local_set(&mod->ref[i].count, 0);
+		local_set(&mod->mod.ref[i].count, 0);
 	/* Hold reference count during initialization. */
-	local_set(&mod->ref[raw_smp_processor_id()].count, 1);
+	local_set(&mod->mod.ref[raw_smp_processor_id()].count, 1);
 	/* Backwards compatibility macros put refcount during init. */
 	mod->waiter = current;
 }
@@ -518,11 +518,11 @@ static void module_unload_init(struct mo
 struct module_use
 {
 	struct list_head list;
-	struct module *module_which_uses;
+	struct module_private *module_which_uses;
 };
 
 /* Does a already use b? */
-static int already_uses(struct module *a, struct module *b)
+static int already_uses(struct module_private *a, struct module_private *b)
 {
 	struct module_use *use;
 
@@ -537,34 +537,35 @@ static int already_uses(struct module *a
 }
 
 /* Module a uses b */
-static int use_module(struct module *a, struct module *b)
+static int use_module(struct module_private *a, struct module_private *b)
 {
 	struct module_use *use;
 	int no_warn;
 
-	if (b == NULL || already_uses(a, b)) return 1;
+	if (b == NULL || already_uses(a, b))
+		return 1;
 
-	if (!strong_try_module_get(b))
+	if (!strong_try_module_get(&b->mod))
 		return 0;
 
 	DEBUGP("Allocating new usage for %s.\n", a->name);
 	use = kmalloc(sizeof(*use), GFP_ATOMIC);
 	if (!use) {
-		printk("%s: out of memory loading\n", a->name);
-		module_put(b);
+		printk("%s: out of memory loading\n", a->mod.name);
+		module_put(&b->mod);
 		return 0;
 	}
 
 	use->module_which_uses = a;
 	list_add(&use->list, &b->modules_which_use_me);
-	no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name);
+	no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->mod.name);
 	return 1;
 }
 
 /* Clear the unload stuff of the module. */
-static void module_unload_free(struct module *mod)
+static void module_unload_free(struct module_private *mod)
 {
-	struct module *i;
+	struct module_private *i;
 
 	list_for_each_entry(i, &modules, list) {
 		struct module_use *use;
@@ -572,10 +573,10 @@ static void module_unload_free(struct mo
 		list_for_each_entry(use, &i->modules_which_use_me, list) {
 			if (use->module_which_uses == mod) {
 				DEBUGP("%s unusing %s\n", mod->name, i->name);
-				module_put(i);
+				module_put(&i->mod);
 				list_del(&use->list);
 				kfree(use);
-				sysfs_remove_link(i->holders_dir, mod->name);
+				sysfs_remove_link(i->holders_dir, mod->mod.name);
 				/* There can be at most one match. */
 				break;
 			}
@@ -600,7 +601,7 @@ static inline int try_force_unload(unsig
 
 struct stopref
 {
-	struct module *mod;
+	struct module_private *mod;
 	int flags;
 	int *forced;
 };
@@ -611,17 +612,17 @@ static int __try_stop_module(void *_sref
 	struct stopref *sref = _sref;
 
 	/* If it's not unused, quit unless we are told to block. */
-	if ((sref->flags & O_NONBLOCK) && module_refcount(sref->mod) != 0) {
+	if ((sref->flags & O_NONBLOCK) && module_refcount(&sref->mod->mod) != 0) {
 		if (!(*sref->forced = try_force_unload(sref->flags)))
 			return -EWOULDBLOCK;
 	}
 
 	/* Mark it as dying. */
-	sref->mod->state = MODULE_STATE_GOING;
+	sref->mod->mod.state = MODULE_STATE_GOING;
 	return 0;
 }
 
-static int try_stop_module(struct module *mod, int flags, int *forced)
+static int try_stop_module(struct module_private *mod, int flags, int *forced)
 {
 	struct stopref sref = { mod, flags, forced };
 
@@ -639,16 +640,16 @@ unsigned int module_refcount(struct modu
 EXPORT_SYMBOL(module_refcount);
 
 /* This exists whether we can unload or not */
-static void free_module(struct module *mod);
+static void free_module(struct module_private *mod);
 
-static void wait_for_zero_refcount(struct module *mod)
+static void wait_for_zero_refcount(struct module_private *mod)
 {
 	/* Since we might sleep for some time, drop the semaphore first */
 	mutex_unlock(&module_mutex);
 	for (;;) {
 		DEBUGP("Looking at refcount...\n");
 		set_current_state(TASK_UNINTERRUPTIBLE);
-		if (module_refcount(mod) == 0)
+		if (module_refcount(&mod->mod) == 0)
 			break;
 		schedule();
 	}
@@ -659,7 +660,7 @@ static void wait_for_zero_refcount(struc
 asmlinkage long
 sys_delete_module(const char __user *name_user, unsigned int flags)
 {
-	struct module *mod;
+	struct module_private *mod;
 	char name[MODULE_NAME_LEN];
 	int ret, forced = 0;
 
@@ -686,7 +687,7 @@ sys_delete_module(const char __user *nam
 	}
 
 	/* Doing init or already dying? */
-	if (mod->state != MODULE_STATE_LIVE) {
+	if (mod->mod.state != MODULE_STATE_LIVE) {
 		/* FIXME: if (force), slam module count and wake up
                    waiter --RR */
 		DEBUGP("%s already dying\n", mod->name);
@@ -714,7 +715,7 @@ sys_delete_module(const char __user *nam
 		goto out;
 
 	/* Never wait if forced. */
-	if (!forced && module_refcount(mod) != 0)
+	if (!forced && module_refcount(&mod->mod) != 0)
 		wait_for_zero_refcount(mod);
 
 	/* Final destruction now noone is using it. */
@@ -730,18 +731,18 @@ sys_delete_module(const char __user *nam
 	return ret;
 }
 
-static void print_unload_info(struct seq_file *m, struct module *mod)
+static void print_unload_info(struct seq_file *m, struct module_private *mod)
 {
 	struct module_use *use;
 	int printed_something = 0;
 
-	seq_printf(m, " %u ", module_refcount(mod));
+	seq_printf(m, " %u ", module_refcount(&mod->mod));
 
 	/* Always include a trailing , so userspace can differentiate
            between this and the old multi-field proc format. */
 	list_for_each_entry(use, &mod->modules_which_use_me, list) {
 		printed_something = 1;
-		seq_printf(m, "%s,", use->module_which_uses->name);
+		seq_printf(m, "%s,", use->module_which_uses->mod.name);
 	}
 
 	if (mod->unsafe) {
@@ -760,14 +761,14 @@ static void print_unload_info(struct seq
 
 void __symbol_put(const char *symbol)
 {
-	struct module *owner;
+	struct module_private *owner;
 	unsigned long flags;
 	const unsigned long *crc;
 
 	spin_lock_irqsave(&modlist_lock, flags);
 	if (!__find_symbol(symbol, &owner, &crc, 1))
 		BUG();
-	module_put(owner);
+	module_put(&owner->mod);
 	spin_unlock_irqrestore(&modlist_lock, flags);
 }
 EXPORT_SYMBOL(__symbol_put);
@@ -786,10 +787,10 @@ void symbol_put_addr(void *addr)
 EXPORT_SYMBOL_GPL(symbol_put_addr);
 
 static ssize_t show_refcnt(struct module_attribute *mattr,
-			   struct module *mod, char *buffer)
+			   struct module_private *mod, char *buffer)
 {
 	/* sysfs holds a reference */
-	return sprintf(buffer, "%u\n", module_refcount(mod)-1);
+	return sprintf(buffer, "%u\n", module_refcount(&mod->mod)-1);
 }
 
 static struct module_attribute refcnt = {
@@ -804,7 +805,7 @@ void module_put(struct module *module)
 		local_dec(&module->ref[cpu].count);
 		/* Maybe they're waiting for us to drop reference? */
 		if (unlikely(!module_is_live(module)))
-			wake_up_process(module->waiter);
+			wake_up_process(get_mod_private(module)->waiter);
 		put_cpu();
 	}
 }
@@ -832,11 +833,11 @@ static inline void module_unload_init(st
 #endif /* CONFIG_MODULE_UNLOAD */
 
 static ssize_t show_initstate(struct module_attribute *mattr,
-			   struct module *mod, char *buffer)
+			   struct module_private *mod, char *buffer)
 {
 	const char *state = "unknown";
 
-	switch (mod->state) {
+	switch (mod->mod.state) {
 	case MODULE_STATE_LIVE:
 		state = "live";
 		break;
@@ -871,7 +872,7 @@ static const char vermagic[] = VERMAGIC_
 static int check_version(Elf_Shdr *sechdrs,
 			 unsigned int versindex,
 			 const char *symname,
-			 struct module *mod, 
+			 struct module_private *mod,
 			 const unsigned long *crc)
 {
 	unsigned int i, num_versions;
@@ -892,7 +893,7 @@ static int check_version(Elf_Shdr *sechd
 		if (versions[i].crc == *crc)
 			return 1;
 		printk("%s: disagrees about version of symbol %s\n",
-		       mod->name, symname);
+		       mod->mod.name, symname);
 		DEBUGP("Found checksum %lX vs module %lX\n",
 		       *crc, versions[i].crc);
 		return 0;
@@ -900,17 +901,17 @@ static int check_version(Elf_Shdr *sechd
 	/* Not in module's version table.  OK, but that taints the kernel. */
 	if (!(tainted & TAINT_FORCED_MODULE))
 		printk("%s: no version for \"%s\" found: kernel tainted.\n",
-		       mod->name, symname);
+		       mod->mod.name, symname);
 	add_taint_module(mod, TAINT_FORCED_MODULE);
 	return 1;
 }
 
 static inline int check_modstruct_version(Elf_Shdr *sechdrs,
 					  unsigned int versindex,
-					  struct module *mod)
+					  struct module_private *mod)
 {
 	const unsigned long *crc;
-	struct module *owner;
+	struct module_private *owner;
 
 	if (!__find_symbol("struct_module", &owner, &crc, 1))
 		BUG();
@@ -929,7 +930,7 @@ static inline int same_magic(const char 
 static inline int check_version(Elf_Shdr *sechdrs,
 				unsigned int versindex,
 				const char *symname,
-				struct module *mod, 
+				struct module_private *mod,
 				const unsigned long *crc)
 {
 	return 1;
@@ -937,7 +938,7 @@ static inline int check_version(Elf_Shdr
 
 static inline int check_modstruct_version(Elf_Shdr *sechdrs,
 					  unsigned int versindex,
-					  struct module *mod)
+					  struct module_private *mod)
 {
 	return 1;
 }
@@ -953,9 +954,9 @@ static inline int same_magic(const char 
 static unsigned long resolve_symbol(Elf_Shdr *sechdrs,
 				    unsigned int versindex,
 				    const char *name,
-				    struct module *mod)
+				    struct module_private *mod)
 {
-	struct module *owner;
+	struct module_private *owner;
 	unsigned long ret;
 	const unsigned long *crc;
 
@@ -977,7 +978,7 @@ static unsigned long resolve_symbol(Elf_
  */
 #ifdef CONFIG_KALLSYMS
 static ssize_t module_sect_show(struct module_attribute *mattr,
-				struct module *mod, char *buf)
+				struct module_private *mod, char *buf)
 {
 	struct module_sect_attr *sattr =
 		container_of(mattr, struct module_sect_attr, mattr);
@@ -993,7 +994,7 @@ static void free_sect_attrs(struct modul
 	kfree(sect_attrs);
 }
 
-static void add_sect_attrs(struct module *mod, unsigned int nsect,
+static void add_sect_attrs(struct module_private *mod, unsigned int nsect,
 		char *secstrings, Elf_Shdr *sechdrs)
 {
 	unsigned int nloaded = 0, i, size[2];
@@ -1032,7 +1033,7 @@ static void add_sect_attrs(struct module
 		sattr->mattr.show = module_sect_show;
 		sattr->mattr.store = NULL;
 		sattr->mattr.attr.name = sattr->name;
-		sattr->mattr.attr.owner = mod;
+		sattr->mattr.attr.owner = &mod->mod;
 		sattr->mattr.attr.mode = S_IRUGO;
 		*(gattr++) = &(sattr++)->mattr.attr;
 	}
@@ -1047,7 +1048,7 @@ static void add_sect_attrs(struct module
 	free_sect_attrs(sect_attrs);
 }
 
-static void remove_sect_attrs(struct module *mod)
+static void remove_sect_attrs(struct module_private *mod)
 {
 	if (mod->sect_attrs) {
 		sysfs_remove_group(&mod->mkobj.kobj,
@@ -1072,7 +1073,7 @@ static inline void remove_sect_attrs(str
 #endif /* CONFIG_KALLSYMS */
 
 #ifdef CONFIG_SYSFS
-int module_add_modinfo_attrs(struct module *mod)
+int module_add_modinfo_attrs(struct module_private *mod)
 {
 	struct module_attribute *attr;
 	struct module_attribute *temp_attr;
@@ -1090,7 +1091,7 @@ int module_add_modinfo_attrs(struct modu
 		if (!attr->test ||
 		    (attr->test && attr->test(mod))) {
 			memcpy(temp_attr, attr, sizeof(*temp_attr));
-			temp_attr->attr.owner = mod;
+			temp_attr->attr.owner = &mod->mod;
 			error = sysfs_create_file(&mod->mkobj.kobj,&temp_attr->attr);
 			++temp_attr;
 		}
@@ -1098,7 +1099,7 @@ int module_add_modinfo_attrs(struct modu
 	return error;
 }
 
-void module_remove_modinfo_attrs(struct module *mod)
+void module_remove_modinfo_attrs(struct module_private *mod)
 {
 	struct module_attribute *attr;
 	int i;
@@ -1116,18 +1117,18 @@ void module_remove_modinfo_attrs(struct 
 #endif
 
 #ifdef CONFIG_SYSFS
-int mod_sysfs_init(struct module *mod)
+int mod_sysfs_init(struct module_private *mod)
 {
 	int err;
 
 	if (!module_sysfs_initialized) {
 		printk(KERN_ERR "%s: module sysfs not initialized\n",
-		       mod->name);
+		       mod->mod.name);
 		err = -EINVAL;
 		goto out;
 	}
 	memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));
-	err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
+	err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->mod.name);
 	if (err)
 		goto out;
 	kobj_set_kset_s(&mod->mkobj, module_subsys);
@@ -1139,7 +1140,7 @@ out:
 	return err;
 }
 
-int mod_sysfs_setup(struct module *mod,
+int mod_sysfs_setup(struct module_private *mod,
 			   struct kernel_param *kparam,
 			   unsigned int num_params)
 {
@@ -1179,7 +1180,7 @@ out:
 }
 #endif
 
-static void mod_kobject_remove(struct module *mod)
+static void mod_kobject_remove(struct module_private *mod)
 {
 	module_remove_modinfo_attrs(mod);
 	module_param_sysfs_remove(mod);
@@ -1194,13 +1195,13 @@ static void mod_kobject_remove(struct mo
  */
 static int __unlink_module(void *_mod)
 {
-	struct module *mod = _mod;
+	struct module_private *mod = _mod;
 	list_del(&mod->list);
 	return 0;
 }
 
 /* Free a module, remove from lists, etc (must hold module_mutex). */
-static void free_module(struct module *mod)
+static void free_module(struct module_private *mod)
 {
 	/* Delete from various lists */
 	stop_machine_run(__unlink_module, mod, NR_CPUS);
@@ -1217,9 +1218,9 @@ static void free_module(struct module *m
 
 	/* This may be NULL, but that's OK */
 	module_free(mod, mod->module_init);
-	kfree(mod->args);
-	if (mod->percpu)
-		percpu_modfree(mod->percpu);
+	kfree(mod->mod.args);
+	if (mod->mod.percpu)
+		percpu_modfree(mod->mod.percpu);
 
 	/* Free lock-classes: */
 	lockdep_free_key_range(mod->module_core, mod->core_size);
@@ -1230,13 +1231,13 @@ static void free_module(struct module *m
 
 void *__symbol_get(const char *symbol)
 {
-	struct module *owner;
+	struct module_private *owner;
 	unsigned long value, flags;
 	const unsigned long *crc;
 
 	spin_lock_irqsave(&modlist_lock, flags);
 	value = __find_symbol(symbol, &owner, &crc, 1);
-	if (value && !strong_try_module_get(owner))
+	if (value && !strong_try_module_get(&owner->mod))
 		value = 0;
 	spin_unlock_irqrestore(&modlist_lock, flags);
 
@@ -1248,11 +1249,11 @@ EXPORT_SYMBOL_GPL(__symbol_get);
  * Ensure that an exported symbol [global namespace] does not already exist
  * in the kernel or in some other module's exported symbol table.
  */
-static int verify_export_symbols(struct module *mod)
+static int verify_export_symbols(struct module_private *mod)
 {
 	const char *name = NULL;
 	unsigned long i, ret = 0;
-	struct module *owner;
+	struct module_private *owner;
 	const unsigned long *crc;
 
 	for (i = 0; i < mod->num_syms; i++)
@@ -1272,7 +1273,7 @@ static int verify_export_symbols(struct 
 dup:
 	if (ret)
 		printk(KERN_ERR "%s: exports duplicate symbol %s (owned by %s)\n",
-			mod->name, name, module_name(owner));
+			mod->mod.name, name, module_name(&owner->mod));
 
 	return ret;
 }
@@ -1283,7 +1284,7 @@ static int simplify_symbols(Elf_Shdr *se
 			    const char *strtab,
 			    unsigned int versindex,
 			    unsigned int pcpuindex,
-			    struct module *mod)
+			    struct module_private *mod)
 {
 	Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
 	unsigned long secbase;
@@ -1297,7 +1298,7 @@ static int simplify_symbols(Elf_Shdr *se
 			   supposed to happen.  */
 			DEBUGP("Common symbol: %s\n", strtab + sym[i].st_name);
 			printk("%s: please compile with -fno-common\n",
-			       mod->name);
+			       mod->mod.name);
 			ret = -ENOEXEC;
 			break;
 
@@ -1320,14 +1321,14 @@ static int simplify_symbols(Elf_Shdr *se
 				break;
 
 			printk(KERN_WARNING "%s: Unknown symbol %s\n",
-			       mod->name, strtab + sym[i].st_name);
+			       mod->mod.name, strtab + sym[i].st_name);
 			ret = -ENOENT;
 			break;
 
 		default:
 			/* Divert to percpu allocation if a percpu var. */
 			if (sym[i].st_shndx == pcpuindex)
-				secbase = (unsigned long)mod->percpu;
+				secbase = (unsigned long)mod->mod.percpu;
 			else
 				secbase = sechdrs[sym[i].st_shndx].sh_addr;
 			sym[i].st_value += secbase;
@@ -1352,7 +1353,7 @@ static long get_offset(unsigned long *si
    might -- code, read-only data, read-write data, small data.  Tally
    sizes, and place the offsets into sh_entsize fields: high bit means it
    belongs in init. */
-static void layout_sections(struct module *mod,
+static void layout_sections(struct module_private *mod,
 			    const Elf_Ehdr *hdr,
 			    Elf_Shdr *sechdrs,
 			    const char *secstrings)
@@ -1409,7 +1410,7 @@ static void layout_sections(struct modul
 	}
 }
 
-static void set_license(struct module *mod, const char *license)
+static void set_license(struct module_private *mod, const char *license)
 {
 	if (!license)
 		license = "unspecified";
@@ -1417,7 +1418,7 @@ static void set_license(struct module *m
 	if (!license_is_gpl_compatible(license)) {
 		if (!(tainted & TAINT_PROPRIETARY_MODULE))
 			printk(KERN_WARNING "%s: module license '%s' taints "
-				"kernel.\n", mod->name, license);
+				"kernel.\n", mod->mod.name, license);
 		add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
 	}
 }
@@ -1456,7 +1457,7 @@ static char *get_modinfo(Elf_Shdr *sechd
 	return NULL;
 }
 
-static void setup_modinfo(struct module *mod, Elf_Shdr *sechdrs,
+static void setup_modinfo(struct module_private *mod, Elf_Shdr *sechdrs,
 			  unsigned int infoindex)
 {
 	struct module_attribute *attr;
@@ -1472,7 +1473,7 @@ static void setup_modinfo(struct module 
 }
 
 #ifdef CONFIG_KALLSYMS
-static int is_exported(const char *name, const struct module *mod)
+static int is_exported(const char *name, const struct module_private *mod)
 {
 	if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab))
 		return 1;
@@ -1487,7 +1488,7 @@ static int is_exported(const char *name,
 static char elf_type(const Elf_Sym *sym,
 		     Elf_Shdr *sechdrs,
 		     const char *secstrings,
-		     struct module *mod)
+		     struct module_private *mod)
 {
 	if (ELF_ST_BIND(sym->st_info) == STB_WEAK) {
 		if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT)
@@ -1524,7 +1525,7 @@ static char elf_type(const Elf_Sym *sym,
 	return '?';
 }
 
-static void add_kallsyms(struct module *mod,
+static void add_kallsyms(struct module_private *mod,
 			 Elf_Shdr *sechdrs,
 			 unsigned int symindex,
 			 unsigned int strindex,
@@ -1542,7 +1543,7 @@ static void add_kallsyms(struct module *
 			= elf_type(&mod->symtab[i], sechdrs, secstrings, mod);
 }
 #else
-static inline void add_kallsyms(struct module *mod,
+static inline void add_kallsyms(struct module_private *mod,
 				Elf_Shdr *sechdrs,
 				unsigned int symindex,
 				unsigned int strindex,
@@ -1553,7 +1554,7 @@ static inline void add_kallsyms(struct m
 
 /* Allocate and load the module: note that size of section 0 is always
    zero, and we rely on this for optional sections. */
-static struct module *load_module(void __user *umod,
+static struct module_private *load_module(void __user *umod,
 				  unsigned long len,
 				  const char __user *uargs)
 {
@@ -1581,7 +1582,7 @@ static struct module *load_module(void _
 	unsigned int unusedcrcindex;
 	unsigned int unusedgplindex;
 	unsigned int unusedgplcrcindex;
-	struct module *mod;
+	struct module_private *mod;
 	long err = 0;
 	void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
 	struct exception_table_entry *extable;
@@ -1652,7 +1653,7 @@ static struct module *load_module(void _
 
 	if (symindex == 0) {
 		printk(KERN_WARNING "%s: module has no symbols (stripped?)\n",
-		       mod->name);
+		       mod->mod.name);
 		err = -ENOEXEC;
 		goto free_hdr;
 	}
@@ -1699,10 +1700,10 @@ static struct module *load_module(void _
 	if (!modmagic) {
 		add_taint_module(mod, TAINT_FORCED_MODULE);
 		printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
-		       mod->name);
+		       mod->mod.name);
 	} else if (!same_magic(modmagic, vermagic)) {
 		printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
-		       mod->name, modmagic, vermagic);
+		       mod->mod.name, modmagic, vermagic);
 		err = -ENOEXEC;
 		goto free_hdr;
 	}
@@ -1714,12 +1715,12 @@ static struct module *load_module(void _
 		goto free_hdr;
 	}
 
-	if (find_module(mod->name)) {
+	if (find_module(mod->mod.name)) {
 		err = -EEXIST;
 		goto free_mod;
 	}
 
-	mod->state = MODULE_STATE_COMING;
+	mod->mod.state = MODULE_STATE_COMING;
 
 	/* Allow arches to frob section contents and sizes.  */
 	err = module_frob_arch_sections(hdr, sechdrs, secstrings, mod);
@@ -1730,13 +1731,13 @@ static struct module *load_module(void _
 		/* We have a special allocation for this section. */
 		percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
 					 sechdrs[pcpuindex].sh_addralign,
-					 mod->name);
+					 mod->mod.name);
 		if (!percpu) {
 			err = -ENOMEM;
 			goto free_mod;
 		}
 		sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
-		mod->percpu = percpu;
+		mod->mod.percpu = percpu;
 	}
 
 	/* Determine total sizes, and put offsets in sh_entsize.  For now
@@ -1795,9 +1796,9 @@ static struct module *load_module(void _
 	/* Set up license info based on the info section */
 	set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
 
-	if (strcmp(mod->name, "ndiswrapper") == 0)
+	if (strcmp(mod->mod.name, "ndiswrapper") == 0)
 		add_taint(TAINT_PROPRIETARY_MODULE);
-	if (strcmp(mod->name, "driverloader") == 0)
+	if (strcmp(mod->mod.name, "driverloader") == 0)
 		add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
 
 	/* Set up MODINFO_ATTR fields */
@@ -1842,7 +1843,7 @@ static struct module *load_module(void _
 	    (mod->num_unused_syms && !unusedcrcindex) ||
 	    (mod->num_unused_gpl_syms && !unusedgplcrcindex)) {
 		printk(KERN_WARNING "%s: No versions for exported symbols."
-		       " Tainting kernel.\n", mod->name);
+		       " Tainting kernel.\n", mod->mod.name);
 		add_taint_module(mod, TAINT_FORCED_MODULE);
 	}
 #endif
@@ -1881,7 +1882,7 @@ static struct module *load_module(void _
 	sort_extable(extable, extable + mod->num_exentries);
 
 	/* Finally, copy percpu area over. */
-	percpu_modcopy(mod->percpu, (void *)sechdrs[pcpuindex].sh_addr,
+	percpu_modcopy(mod->mod.percpu, (void *)sechdrs[pcpuindex].sh_addr,
 		       sechdrs[pcpuindex].sh_size);
 
 	add_kallsyms(mod, sechdrs, symindex, strindex, secstrings);
@@ -1908,13 +1909,13 @@ static struct module *load_module(void _
 
 	set_fs(old_fs);
 
-	mod->args = args;
+	mod->mod.args = args;
 	if (obsparmindex)
 		printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
-		       mod->name);
+		       mod->mod.name);
 
 	/* Size of section 0 is 0, so this works well if no params */
-	err = parse_args(mod->name, mod->args,
+	err = parse_args(mod->mod.name, mod->mod.args,
 			 (struct kernel_param *)
 			 sechdrs[setupindex].sh_addr,
 			 sechdrs[setupindex].sh_size
@@ -1971,7 +1972,7 @@ static struct module *load_module(void _
  */
 static int __link_module(void *_mod)
 {
-	struct module *mod = _mod;
+	struct module_private *mod = _mod;
 	list_add(&mod->list, &modules);
 	return 0;
 }
@@ -1982,7 +1983,7 @@ sys_init_module(void __user *umod,
 		unsigned long len,
 		const char __user *uargs)
 {
-	struct module *mod;
+	struct module_private *mod;
 	int ret = 0;
 
 	/* Must have permission */
@@ -2016,13 +2017,13 @@ sys_init_module(void __user *umod,
 	if (ret < 0) {
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */
-		mod->state = MODULE_STATE_GOING;
+		mod->mod.state = MODULE_STATE_GOING;
 		synchronize_sched();
 		if (mod->unsafe)
 			printk(KERN_ERR "%s: module is now stuck!\n",
-			       mod->name);
+			       mod->mod.name);
 		else {
-			module_put(mod);
+			module_put(&mod->mod);
 			mutex_lock(&module_mutex);
 			free_module(mod);
 			mutex_unlock(&module_mutex);
@@ -2032,9 +2033,9 @@ sys_init_module(void __user *umod,
 
 	/* Now it's a first class citizen! */
 	mutex_lock(&module_mutex);
-	mod->state = MODULE_STATE_LIVE;
+	mod->mod.state = MODULE_STATE_LIVE;
 	/* Drop initial reference. */
-	module_put(mod);
+	module_put(&mod->mod);
 	unwind_remove_table(mod->unwind_info, 1);
 	module_free(mod, mod->module_init);
 	mod->module_init = NULL;
@@ -2061,7 +2062,7 @@ static inline int is_arm_mapping_symbol(
 	       && (str[2] == '\0' || str[2] == '.');
 }
 
-static const char *get_ksymbol(struct module *mod,
+static const char *get_ksymbol(struct module_private *mod,
 			       unsigned long addr,
 			       unsigned long *size,
 			       unsigned long *offset)
@@ -2113,13 +2114,13 @@ const char *module_address_lookup(unsign
 				  unsigned long *offset,
 				  char **modname)
 {
-	struct module *mod;
+	struct module_private *mod;
 
 	list_for_each_entry(mod, &modules, list) {
 		if (within(addr, mod->module_init, mod->init_size)
 		    || within(addr, mod->module_core, mod->core_size)) {
 			if (modname)
-				*modname = mod->name;
+				*modname = mod->mod.name;
 			return get_ksymbol(mod, addr, size, offset);
 		}
 	}
@@ -2128,7 +2129,7 @@ const char *module_address_lookup(unsign
 
 int lookup_module_symbol_name(unsigned long addr, char *symname)
 {
-	struct module *mod;
+	struct module_private *mod;
 
 	mutex_lock(&module_mutex);
 	list_for_each_entry(mod, &modules, list) {
@@ -2152,7 +2153,7 @@ out:
 int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
 			unsigned long *offset, char *modname, char *name)
 {
-	struct module *mod;
+	struct module_private *mod;
 
 	mutex_lock(&module_mutex);
 	list_for_each_entry(mod, &modules, list) {
@@ -2164,7 +2165,7 @@ int lookup_module_symbol_attrs(unsigned 
 			if (!sym)
 				goto out;
 			if (modname)
-				strlcpy(modname, mod->name, MODULE_NAME_LEN + 1);
+				strlcpy(modname, mod->mod.name, MODULE_NAME_LEN + 1);
 			if (name)
 				strlcpy(name, sym, KSYM_NAME_LEN + 1);
 			mutex_unlock(&module_mutex);
@@ -2179,7 +2180,7 @@ out:
 int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
 			char *name, char *module_name, int *exported)
 {
-	struct module *mod;
+	struct module_private *mod;
 
 	mutex_lock(&module_mutex);
 	list_for_each_entry(mod, &modules, list) {
@@ -2188,7 +2189,7 @@ int module_get_kallsym(unsigned int symn
 			*type = mod->symtab[symnum].st_info;
 			strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
 				KSYM_NAME_LEN + 1);
-			strlcpy(module_name, mod->name, MODULE_NAME_LEN + 1);
+			strlcpy(module_name, mod->mod.name, MODULE_NAME_LEN + 1);
 			*exported = is_exported(name, mod);
 			mutex_unlock(&module_mutex);
 			return 0;
@@ -2199,7 +2200,7 @@ int module_get_kallsym(unsigned int symn
 	return -ERANGE;
 }
 
-static unsigned long mod_find_symname(struct module *mod, const char *name)
+static unsigned long mod_find_symname(struct module_private *mod, const char *name)
 {
 	unsigned int i;
 
@@ -2213,7 +2214,7 @@ static unsigned long mod_find_symname(st
 /* Look for this name: can be of form module:name. */
 unsigned long module_kallsyms_lookup_name(const char *name)
 {
-	struct module *mod;
+	struct module_private *mod;
 	char *colon;
 	unsigned long ret = 0;
 
@@ -2286,17 +2287,17 @@ static char *taint_flags(unsigned int ta
 
 static int m_show(struct seq_file *m, void *p)
 {
-	struct module *mod = list_entry(p, struct module, list);
+	struct module_private *mod = list_entry(p, struct module_private, list);
 	char buf[8];
 
 	seq_printf(m, "%s %lu",
-		   mod->name, mod->init_size + mod->core_size);
+		   mod->mod.name, mod->init_size + mod->core_size);
 	print_unload_info(m, mod);
 
 	/* Informative for users. */
 	seq_printf(m, " %s",
-		   mod->state == MODULE_STATE_GOING ? "Unloading":
-		   mod->state == MODULE_STATE_COMING ? "Loading":
+		   mod->mod.state == MODULE_STATE_GOING ? "Unloading":
+		   mod->mod.state == MODULE_STATE_COMING ? "Loading":
 		   "Live");
 	/* Used by oprofile and other similar tools. */
 	seq_printf(m, " 0x%p", mod->module_core);
@@ -2326,7 +2327,7 @@ const struct exception_table_entry *sear
 {
 	unsigned long flags;
 	const struct exception_table_entry *e = NULL;
-	struct module *mod;
+	struct module_private *mod;
 
 	spin_lock_irqsave(&modlist_lock, flags);
 	list_for_each_entry(mod, &modules, list) {
@@ -2352,7 +2353,7 @@ const struct exception_table_entry *sear
 int is_module_address(unsigned long addr)
 {
 	unsigned long flags;
-	struct module *mod;
+	struct module_private *mod;
 
 	spin_lock_irqsave(&modlist_lock, flags);
 
@@ -2372,12 +2373,12 @@ int is_module_address(unsigned long addr
 /* Is this a valid kernel address?  We don't grab the lock: we are oopsing. */
 struct module *__module_text_address(unsigned long addr)
 {
-	struct module *mod;
+	struct module_private *mod;
 
 	list_for_each_entry(mod, &modules, list)
 		if (within(addr, mod->module_init, mod->init_text_size)
 		    || within(addr, mod->module_core, mod->core_text_size))
-			return mod;
+			return &mod->mod;
 	return NULL;
 }
 
@@ -2396,12 +2397,12 @@ struct module *module_text_address(unsig
 /* Don't grab lock, we're oopsing. */
 void print_modules(void)
 {
-	struct module *mod;
+	struct module_private *mod;
 	char buf[8];
 
 	printk("Modules linked in:");
 	list_for_each_entry(mod, &modules, list)
-		printk(" %s%s", mod->name, taint_flags(mod->taints, buf));
+		printk(" %s%s", mod->mod.name, taint_flags(mod->taints, buf));
 	printk("\n");
 }
 
@@ -2427,7 +2428,7 @@ static void module_create_drivers_dir(st
 	mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
 }
 
-void module_add_driver(struct module *mod, struct device_driver *drv)
+void module_add_driver(struct module_private *mod, struct device_driver *drv)
 {
 	char *driver_name;
 	int no_warn;
@@ -2478,7 +2479,7 @@ void module_remove_driver(struct device_
 	sysfs_remove_link(&drv->kobj, "module");
 
 	if (drv->owner)
-		mk = &drv->owner->mkobj;
+		mk = &get_mod_private(drv->owner)->mkobj;
 	else if (drv->mkobj)
 		mk = drv->mkobj;
 	if (mk && mk->drivers_dir) {
Index: linux-2.6/kernel/params.c
===================================================================
--- linux-2.6.orig/kernel/params.c
+++ linux-2.6/kernel/params.c
@@ -15,6 +15,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
+#include <linux/moduleloader.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -397,7 +398,7 @@ struct module_param_attrs
 #define to_param_attr(n) container_of(n, struct param_attribute, mattr);
 
 static ssize_t param_attr_show(struct module_attribute *mattr,
-			       struct module *mod, char *buf)
+			       struct module_private *mod, char *buf)
 {
 	int count;
 	struct param_attribute *attribute = to_param_attr(mattr);
@@ -415,7 +416,7 @@ static ssize_t param_attr_show(struct mo
 
 /* sysfs always hands a nul-terminated string in buf.  We rely on that. */
 static ssize_t param_attr_store(struct module_attribute *mattr,
-				struct module *owner,
+				struct module_private *owner,
 				const char *buf, size_t len)
 {
  	int err;
@@ -491,7 +492,7 @@ param_sysfs_setup(struct module_kobject 
 			pattr->mattr.show = param_attr_show;
 			pattr->mattr.store = param_attr_store;
 			pattr->mattr.attr.name = (char *)&kp->name[name_skip];
-			pattr->mattr.attr.owner = mk->mod;
+			pattr->mattr.attr.owner = &mk->mod->mod;
 			pattr->mattr.attr.mode = kp->perm;
 			*(gattr++) = &(pattr++)->mattr.attr;
 		}
@@ -515,7 +516,7 @@ param_sysfs_setup(struct module_kobject 
  * Adds sysfs entries for module parameters, and creates a link from
  * /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
  */
-int module_param_sysfs_setup(struct module *mod,
+int module_param_sysfs_setup(struct module_private *mod,
 			     struct kernel_param *kparam,
 			     unsigned int num_params)
 {
@@ -536,7 +537,7 @@ int module_param_sysfs_setup(struct modu
  * Remove sysfs entries for module parameters and the corresponding
  * kobject.
  */
-void module_param_sysfs_remove(struct module *mod)
+void module_param_sysfs_remove(struct module_private *mod)
 {
 	if (mod->param_attrs) {
 		sysfs_remove_group(&mod->mkobj.kobj,
@@ -563,7 +564,7 @@ static void __init kernel_param_sysfs_se
 	mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
 	BUG_ON(!mk);
 
-	mk->mod = THIS_MODULE;
+	mk->mod = get_mod_private(THIS_MODULE);
 	kobj_set_kset_s(mk, module_subsys);
 	kobject_set_name(&mk->kobj, name);
 	kobject_init(&mk->kobj);
Index: linux-2.6/arch/i386/kernel/module.c
===================================================================
--- linux-2.6.orig/arch/i386/kernel/module.c
+++ linux-2.6/arch/i386/kernel/module.c
@@ -38,7 +38,7 @@ void *module_alloc(unsigned long size)
 
 
 /* Free memory returned from module_alloc */
-void module_free(struct module *mod, void *module_region)
+void module_free(struct module_private *mod, void *module_region)
 {
 	vfree(module_region);
 	/* FIXME: If module_region == mod->init_region, trim exception
@@ -49,7 +49,7 @@ void module_free(struct module *mod, voi
 int module_frob_arch_sections(Elf_Ehdr *hdr,
 			      Elf_Shdr *sechdrs,
 			      char *secstrings,
-			      struct module *mod)
+			      struct module_private *mod)
 {
 	return 0;
 }
@@ -58,7 +58,7 @@ int apply_relocate(Elf32_Shdr *sechdrs,
 		   const char *strtab,
 		   unsigned int symindex,
 		   unsigned int relsec,
-		   struct module *me)
+		   struct module_private *me)
 {
 	unsigned int i;
 	Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
@@ -87,7 +87,7 @@ int apply_relocate(Elf32_Shdr *sechdrs,
 			break;
 		default:
 			printk(KERN_ERR "module %s: Unknown relocation: %u\n",
-			       me->name, ELF32_R_TYPE(rel[i].r_info));
+			       me->mod.name, ELF32_R_TYPE(rel[i].r_info));
 			return -ENOEXEC;
 		}
 	}
@@ -98,16 +98,16 @@ int apply_relocate_add(Elf32_Shdr *sechd
 		       const char *strtab,
 		       unsigned int symindex,
 		       unsigned int relsec,
-		       struct module *me)
+		       struct module_private *me)
 {
 	printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
-	       me->name);
+	       me->mod.name);
 	return -ENOEXEC;
 }
 
 int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
-		    struct module *me)
+		    struct module_private *me)
 {
 	const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
 		*para = NULL;
@@ -132,7 +132,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 	if (locks && text) {
 		void *lseg = (void *)locks->sh_addr;
 		void *tseg = (void *)text->sh_addr;
-		alternatives_smp_module_add(me, me->name,
+		alternatives_smp_module_add(&me->mod, me->mod.name,
 					    lseg, lseg + locks->sh_size,
 					    tseg, tseg + text->sh_size);
 	}
@@ -142,11 +142,11 @@ int module_finalize(const Elf_Ehdr *hdr,
 		apply_paravirt(pseg, pseg + para->sh_size);
 	}
 
-	return module_bug_finalize(hdr, sechdrs, me);
+	return module_bug_finalize(hdr, sechdrs, &me->mod);
 }
 
-void module_arch_cleanup(struct module *mod)
+void module_arch_cleanup(struct module_private *mod)
 {
-	alternatives_smp_module_del(mod);
-	module_bug_cleanup(mod);
+	alternatives_smp_module_del(&mod->mod);
+	module_bug_cleanup(&mod->mod);
 }
Index: linux-2.6/drivers/base/bus.c
===================================================================
--- linux-2.6.orig/drivers/base/bus.c
+++ linux-2.6/drivers/base/bus.c
@@ -9,7 +9,7 @@
  */
 
 #include <linux/device.h>
-#include <linux/module.h>
+#include <linux/moduleloader.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/string.h>
@@ -619,7 +619,7 @@ int bus_add_driver(struct device_driver 
 			goto out_unregister;
 	}
 	klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
-	module_add_driver(drv->owner, drv);
+	module_add_driver(get_mod_private(drv->owner), drv);
 
 	error = driver_add_attrs(bus, drv);
 	if (error) {
Index: linux-2.6/scripts/mod/modpost.c
===================================================================
--- linux-2.6.orig/scripts/mod/modpost.c
+++ linux-2.6/scripts/mod/modpost.c
@@ -1314,15 +1314,17 @@ static void check_exports(struct module 
  **/
 static void add_header(struct buffer *b, struct module *mod)
 {
-	buf_printf(b, "#include <linux/module.h>\n");
+	buf_printf(b, "#include <linux/moduleloader.h>\n");
 	buf_printf(b, "#include <linux/vermagic.h>\n");
 	buf_printf(b, "#include <linux/compiler.h>\n");
 	buf_printf(b, "\n");
 	buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
 	buf_printf(b, "\n");
-	buf_printf(b, "struct module __this_module\n");
+	buf_printf(b, "struct module_private __this_module_private\n");
 	buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
-	buf_printf(b, " .name = KBUILD_MODNAME,\n");
+	buf_printf(b, " .mod = {\n");
+	buf_printf(b, "  .name = KBUILD_MODNAME,\n");
+	buf_printf(b, " },\n");
 	if (mod->has_init)
 		buf_printf(b, " .init = init_module,\n");
 	if (mod->has_cleanup)
@@ -1331,6 +1333,7 @@ static void add_header(struct buffer *b,
 			      "#endif\n");
 	buf_printf(b, " .arch = MODULE_ARCH_INIT,\n");
 	buf_printf(b, "};\n");
+	buf_printf(b, "asm (\".globl __this_module; .type __this_module,@object; __this_module = __this_module_private\");\n");
 }
 
 /**

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-27 23:25       ` Roman Zippel
@ 2007-06-28 15:45         ` Jeremy Fitzhardinge
  2007-06-28 21:48           ` Roman Zippel
  0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-28 15:45 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch, Al Viro

Roman Zippel wrote:
> This could be avoided by reordering things within elf.h, but is it really 
> necessary since there is no user of this right now?
>   

Well, yes, I don't have much need to include ELF headers in asm now, but 
I still think its worth separating the arch-specific definitions from 
asm/elf.h and all the other stuff they pull in.  Specifically, the 
structure forward declarations and constants have very few external 
dependencies, but the structure definitions - particularly the 
arch-specific ones - have very wide dependencies, which is what I'm 
trying to solve.  Very few pieces of code care about the arch-specific 
structures.

> module.h does indeed pull in way too much, but instead of hacking headers 
> into little pieces, IMO it would be better to solve the real problem.
>   

No, that's not the real problem; its a side-effect of the real problem.  
The real problem is that linux/elf.h ends up bringing in too much.  
arch/powerpc, for example, has its own stripped down copy of elf.h for 
bootloader stuff in order to avoid this extra crud.  The fix is to make 
it possible to get just the appropriate ELF definitions without getting 
everything else.

There's the secondary problem that lots of ELF stuff is copy'n'paste 
duplicated across all the architectures, but all they really care about 
is one of two sets of parallel definitions (32 or 64 ELF structures).  
That was the secondary

> I played with it a little and the patch below moves a lot stuff out of 
> module.h, so this would drastically reduce the header dependencies.
> Unless there are major objections, I can test the patch a little more and 
> convert the other archs.
>   

Well, it seems like a large fiddly patch which only solves part of the 
problem I want to solve; actually it doesn't help me at all, but it 
achieves one of the side-effects of my patch. The arch changes make it 
look pretty awkward to merge.

    J


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-28 15:45         ` Jeremy Fitzhardinge
@ 2007-06-28 21:48           ` Roman Zippel
  2007-06-29 14:53             ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 24+ messages in thread
From: Roman Zippel @ 2007-06-28 21:48 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch, Al Viro

Hi,

On Thu, 28 Jun 2007, Jeremy Fitzhardinge wrote:

> Roman Zippel wrote:
> > This could be avoided by reordering things within elf.h, but is it really
> > necessary since there is no user of this right now?
> >   
> 
> Well, yes, I don't have much need to include ELF headers in asm now, but I
> still think its worth separating the arch-specific definitions from asm/elf.h
> and all the other stuff they pull in.  Specifically, the structure forward
> declarations and constants have very few external dependencies, but the
> structure definitions - particularly the arch-specific ones - have very wide
> dependencies, which is what I'm trying to solve.  Very few pieces of code care
> about the arch-specific structures.

The problem I have is that you want to separate _all_ constants, which 
doesn't really make sense to me, because many of them are useless without 
the correspending structures.

> > module.h does indeed pull in way too much, but instead of hacking headers
> > into little pieces, IMO it would be better to solve the real problem.
> >   
> 
> No, that's not the real problem; its a side-effect of the real problem.  The
> real problem is that linux/elf.h ends up bringing in too much.

Please define the problem more specific. :)

>  arch/powerpc,
> for example, has its own stripped down copy of elf.h for bootloader stuff in
> order to avoid this extra crud.  The fix is to make it possible to get just
> the appropriate ELF definitions without getting everything else.

The bootloader is no kernel code and thus the elf header pull in a lot 
less:

$ gcc -c foo.c -Iusr/include --trace-includes
. usr/include/linux/elf.h
.. usr/include/linux/types.h
... usr/include/linux/posix_types.h
.... usr/include/linux/stddef.h
.... usr/include/asm/posix_types.h
... usr/include/asm/types.h
.. usr/include/linux/auxvec.h
... usr/include/asm/auxvec.h
.. usr/include/linux/elf-em.h
.. usr/include/asm/elf.h
... usr/include/asm/ptrace.h
.... usr/include/asm/ptrace-abi.h
... usr/include/asm/user.h
.... usr/include/asm/page.h

One could remove ptrace.h but otherwise the result looks quite reasonable.

> There's the secondary problem that lots of ELF stuff is copy'n'paste
> duplicated across all the architectures, but all they really care about is one
> of two sets of parallel definitions (32 or 64 ELF structures).  That was the
> secondary

Some of it you could put into linux/elf, e.g.:

#if ELF_CLASS == ELFCLASS32

typedef Elf32_Ehdr     Elf_Ehdr;
typedef Elf32_Phdr     Elf_Phdr;
typedef Elf32_Shdr     Elf_Shdr;
typedef Elf32_Sym      Elf_Sym;
typedef Elf32_Dyn      Elf_Dyn;
typedef Elf32_Rel      Elf_Rel;
typedef Elf32_Rela     Elf_Rela;

typedef Elf32_Addr     Elf_Addr;

#elif ELF_CLASS == ELFCLASS64

typedef Elf64_Ehdr     Elf_Ehdr;
typedef Elf64_Phdr     Elf_Phdr;
typedef Elf64_Shdr     Elf_Shdr;
typedef Elf64_Sym      Elf_Sym;
typedef Elf64_Dyn      Elf_Dyn;
typedef Elf64_Rel      Elf_Rel;
typedef Elf64_Rela     Elf_Rela;

typedef Elf64_Addr     Elf_Addr;

#else
#error
#endif

> > I played with it a little and the patch below moves a lot stuff out of
> > module.h, so this would drastically reduce the header dependencies.
> > Unless there are major objections, I can test the patch a little more and
> > convert the other archs.
> >   
> 
> Well, it seems like a large fiddly patch which only solves part of the problem
> I want to solve; actually it doesn't help me at all, but it achieves one of
> the side-effects of my patch. The arch changes make it look pretty awkward to
> merge.

The patch does help you quite a bit, you don't have to cleanup elf.h so 
it's usable by the whole kernel. Only few parts now really need it and 
depend on it, which makes the extensive splitup unnecessary only to 
reduce header dependencies.

bye, Roman

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
                     ` (4 preceding siblings ...)
  2007-06-25 15:18   ` Roman Zippel
@ 2007-06-29  4:13   ` Paul Mackerras
  2007-06-29  5:31     ` Jeremy Fitzhardinge
  2007-06-29  4:48   ` Paul Mackerras
  6 siblings, 1 reply; 24+ messages in thread
From: Paul Mackerras @ 2007-06-29  4:13 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Martin Schwidefsky, Paul Mundt, David S. Miller,
	Miles Bader, Chris Zankel

Jeremy Fitzhardinge writes:

>   powerpc also appears to have its own duplicate copy of elf.h in
>   arch/powerpc/boot/elf.h; presumably because the standard elf.h
>   brings in too much.  Update it to just linux/elf-defn.h, which
>   should be fine.

No, it's because the bootwrapper is not part of the kernel and does
not use kernel headers.  The aim is that the bootwrapper can be built
and used outside the kernel source tree, so it needs its own copies of
any headers that aren't in /usr/include.

Paul.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
                     ` (5 preceding siblings ...)
  2007-06-29  4:13   ` Paul Mackerras
@ 2007-06-29  4:48   ` Paul Mackerras
  2007-06-29  5:31     ` Jeremy Fitzhardinge
  6 siblings, 1 reply; 24+ messages in thread
From: Paul Mackerras @ 2007-06-29  4:48 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Martin Schwidefsky, Paul Mundt, David S. Miller,
	Miles Bader, Chris Zankel

Jeremy Fitzhardinge writes:

> ===================================================================
> --- a/arch/powerpc/platforms/cell/io-workarounds.c
> +++ b/arch/powerpc/platforms/cell/io-workarounds.c
> @@ -9,6 +9,7 @@
>  #undef DEBUG
>  
>  #include <linux/kernel.h>
> +#include <linux/sched.h>

Why is this needed?  You've added #include <linux/sched.h> to 7 files
without explanation - and I can't see that you have removed a
corresponding #include from any header, have you?

Paul.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-29  4:48   ` Paul Mackerras
@ 2007-06-29  5:31     ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-29  5:31 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Martin Schwidefsky, Paul Mundt, David S. Miller,
	Miles Bader, Chris Zankel

Paul Mackerras wrote:
>> ===================================================================
>> --- a/arch/powerpc/platforms/cell/io-workarounds.c
>> +++ b/arch/powerpc/platforms/cell/io-workarounds.c
>> @@ -9,6 +9,7 @@
>>  #undef DEBUG
>>  
>>  #include <linux/kernel.h>
>> +#include <linux/sched.h>
>>     
>
> Why is this needed?  You've added #include <linux/sched.h> to 7 files
> without explanation - and I can't see that you have removed a
> corresponding #include from any header, have you?
>   

asm-powerpc/elf.h included sched.h, and it in turn was being included by 
something else.  With the cleanups in this patch, asm-powerpc/elf.h is 
no longer being included, so io-workarounds.c needs kernel/sched.h for a 
declaration of init_mm.

Similarly with the others; they all failed to compile without linux/sched.h.

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-29  4:13   ` Paul Mackerras
@ 2007-06-29  5:31     ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-29  5:31 UTC (permalink / raw)
  To: Paul Mackerras
  Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Richard Henderson, Ian Molton, Russell King, Haavard Skinnemoen,
	Aubrey Li, Mikael Starvik, David Howells, Yoshinori Sato,
	Andi Kleen, Tony Luck, Geert Uytterhoeven, Ralf Baechle,
	Matthew Wilcox, Martin Schwidefsky, Paul Mundt, David S. Miller,
	Miles Bader, Chris Zankel

Paul Mackerras wrote:
> No, it's because the bootwrapper is not part of the kernel and does
> not use kernel headers.  The aim is that the bootwrapper can be built
> and used outside the kernel source tree, so it needs its own copies of
> any headers that aren't in /usr/include.
>   

Hm, I see.  But <elf.h> is generally available, isn't it?

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-28 21:48           ` Roman Zippel
@ 2007-06-29 14:53             ` Jeremy Fitzhardinge
  2007-06-29 18:12               ` Sam Ravnborg
  0 siblings, 1 reply; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-29 14:53 UTC (permalink / raw)
  To: Roman Zippel; +Cc: Eric W. Biederman, lkml, Andrew Morton, Linux Arch, Al Viro

Roman Zippel wrote:
> The problem I have is that you want to separate _all_ constants, which 
> doesn't really make sense to me, because many of them are useless without 
> the correspending structures.
>   

It seems cleanest to just put all the constants in one place rather than 
scatter them around based on how they happen to be used.


>>> module.h does indeed pull in way too much, but instead of hacking headers
>>> into little pieces, IMO it would be better to solve the real problem.
>>>   
>>>       
>> No, that's not the real problem; its a side-effect of the real problem.  The
>> real problem is that linux/elf.h ends up bringing in too much.
>>     
>
> Please define the problem more specific. :)
>   

I want to be able to include a header to get just the ELF type and 
constant definitions with no other crud.  Both arch-independent ELF 
definitions, and the ones parameterised by ELF_CLASS.

I want this for three reasons:

   1. one is the general cleanup that allows people to use
      forward-declared ELF types in general kernel headers without
      needing to pull in the full set of ELF headers
   2. and to be able to pull full ELF declarations into code which can't
      deal with Linux headers, such as bootloader code which doesn't
      compile in the same universe as the rest of the kernel
   3. a way of getting arch-dependent but broadly common ELF parameters
      in a consistent way

This is complicated by the fact that each architecture needs to define 
some arch-dependent ELF structures which will end up having wider 
dependencies.  The classic example is the ELF note for core files which 
contains register and other process state, and that will naturally pull 
in a bunch of other headers to implement that.  Unfortunately, the 
current structure of the ELF headers mean that any user with the 
slightest interest in ELF structures will end up pulling in half the 
kernel headers via the asm/elf.h includes.

So my solution was to factor the ELF definitions into useful groups that 
allow the various users to pull in what they need.  The breakdown is:

    * arch-independent ELF forward declarations: linux/elf-decl.h
    * arch-independent constants: linux/elf-const.h
    * arch-independent ELF structure definitions: linux/elf-defn.h
    * arch-parameterised ELF declarations: asm/elf-defines.h

and because more or less all the architectures do the same thing for 
their parameterised ELF types (albeit inconsistently), I pulled the 
implementation into asm-generic/elf{32,64}-defines.h, and the typical 
asm/elf-defines.h ends up being a single line to include the appropriate 
one.

I'd agree that linux/elf-const.h and linux/elf-decl.h could probably be 
folded together.

>>  arch/powerpc,
>> for example, has its own stripped down copy of elf.h for bootloader stuff in
>> order to avoid this extra crud.  The fix is to make it possible to get just
>> the appropriate ELF definitions without getting everything else.
>>     
>
> The bootloader is no kernel code and thus the elf header pull in a lot 
> less:
>
> $ gcc -c foo.c -Iusr/include --trace-includes
> . usr/include/linux/elf.h
> .. usr/include/linux/types.h
> ... usr/include/linux/posix_types.h
> .... usr/include/linux/stddef.h
> .... usr/include/asm/posix_types.h
> ... usr/include/asm/types.h
> .. usr/include/linux/auxvec.h
> ... usr/include/asm/auxvec.h
> .. usr/include/linux/elf-em.h
> .. usr/include/asm/elf.h
> ... usr/include/asm/ptrace.h
> .... usr/include/asm/ptrace-abi.h
> ... usr/include/asm/user.h
> .... usr/include/asm/page.h
>
> One could remove ptrace.h but otherwise the result looks quite reasonable.
>   

Which architecture?  The variation of other includes in the various 
asm-*/elf.h headers is very broad.

On i386, it ends up being dependent on the mach-* subarch mess, which 
doesn't work in the boot code.  Since there's nothing about the ELF 
definitions which is subarch-dependent, so that's clearly a bogus 
dependency.

>> There's the secondary problem that lots of ELF stuff is copy'n'paste
>> duplicated across all the architectures, but all they really care about is one
>> of two sets of parallel definitions (32 or 64 ELF structures).  That was the
>> secondary
>>     
>
> Some of it you could put into linux/elf, e.g.:
>
> #if ELF_CLASS == ELFCLASS32
>
> typedef Elf32_Ehdr     Elf_Ehdr;
> typedef Elf32_Phdr     Elf_Phdr;
> typedef Elf32_Shdr     Elf_Shdr;
> typedef Elf32_Sym      Elf_Sym;
> typedef Elf32_Dyn      Elf_Dyn;
> typedef Elf32_Rel      Elf_Rel;
> typedef Elf32_Rela     Elf_Rela;
>
> typedef Elf32_Addr     Elf_Addr;
>
> #elif ELF_CLASS == ELFCLASS64
>
> typedef Elf64_Ehdr     Elf_Ehdr;
> typedef Elf64_Phdr     Elf_Phdr;
> typedef Elf64_Shdr     Elf_Shdr;
> typedef Elf64_Sym      Elf_Sym;
> typedef Elf64_Dyn      Elf_Dyn;
> typedef Elf64_Rel      Elf_Rel;
> typedef Elf64_Rela     Elf_Rela;
>
> typedef Elf64_Addr     Elf_Addr;
>
> #else
> #error
> #endif
>   

Yes, but it does get a bit subtle.  x86-64 does strange things with 
redefining the ELF class to compile a 32-bit binfmt_elf, and I think 
other architectures play similar games.   Rearranging these headers is 
pretty fragile, and I think my approach is a bit less likely to 
(possibly) break things.  But I haven't cross-compiled all the 
architectures, so I may have broken stuff anyway.

> The patch does help you quite a bit, you don't have to cleanup elf.h so 
> it's usable by the whole kernel. Only few parts now really need it and 
> depend on it, which makes the extensive splitup unnecessary only to 
> reduce header dependencies.
>   

Yes, but only for the module.h case.  My concerns are wider.

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-29 14:53             ` Jeremy Fitzhardinge
@ 2007-06-29 18:12               ` Sam Ravnborg
  2007-07-01 16:23                 ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 24+ messages in thread
From: Sam Ravnborg @ 2007-06-29 18:12 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Roman Zippel, Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Al Viro

On Fri, Jun 29, 2007 at 10:53:39AM -0400, Jeremy Fitzhardinge wrote:
> Roman Zippel wrote:
> >The problem I have is that you want to separate _all_ constants, which 
> >doesn't really make sense to me, because many of them are useless without 
> >the correspending structures.
> >  
> 
> It seems cleanest to just put all the constants in one place rather than 
> scatter them around based on how they happen to be used.

Grouping related things together is always a good approach. But the right
factor should be used for the grouping. For the ELF file is would from a usage
perspective be natural to have constants close to the definition that
they are used to describe. Having constants grouped with other constants just
_because_ they are constants does not cut here.

	Sam

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH] cross-architecture ELF clean up
  2007-06-29 18:12               ` Sam Ravnborg
@ 2007-07-01 16:23                 ` Jeremy Fitzhardinge
  0 siblings, 0 replies; 24+ messages in thread
From: Jeremy Fitzhardinge @ 2007-07-01 16:23 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Roman Zippel, Eric W. Biederman, lkml, Andrew Morton, Linux Arch,
	Al Viro

Sam Ravnborg wrote:
> Grouping related things together is always a good approach. But the right
> factor should be used for the grouping. For the ELF file is would from a usage
> perspective be natural to have constants close to the definition that
> they are used to describe. Having constants grouped with other constants just
> _because_ they are constants does not cut here.

Many ELF constants are used without direct reference to their 
corresponding structures.  My linux/elf-const.h header is just a 
generalization of the existing linux/elf-em.h header, which just 
contained the ELF EM_* constants.  Given that there seems to be a 
preexisting need for the EM_* constants in a separate header, and having 
a separate elf-*.h for each group of constants is a bad idea, it seemed 
to me that elf-const.h was the appropriate direction to take.

    J

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2007-07-01 16:23 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20070620230854.246399397@goop.org>
2007-06-20 23:08 ` [PATCH] cross-architecture ELF clean up Jeremy Fitzhardinge
2007-06-21  8:20   ` ian
2007-06-21 15:06     ` Jeremy Fitzhardinge
2007-06-21 16:49   ` Chris Zankel
2007-06-21 18:31     ` Jeremy Fitzhardinge
2007-06-25  9:02   ` David Woodhouse
2007-06-25 12:43     ` Jeremy Fitzhardinge
2007-06-25 13:40     ` Roman Zippel
2007-06-25 13:56       ` Clemens Koller
2007-06-25 14:06         ` Roman Zippel
2007-06-25 13:37   ` Roman Zippel
2007-06-26 19:29     ` Jeremy Fitzhardinge
2007-06-27 23:25       ` Roman Zippel
2007-06-28 15:45         ` Jeremy Fitzhardinge
2007-06-28 21:48           ` Roman Zippel
2007-06-29 14:53             ` Jeremy Fitzhardinge
2007-06-29 18:12               ` Sam Ravnborg
2007-07-01 16:23                 ` Jeremy Fitzhardinge
2007-06-25 15:18   ` Roman Zippel
2007-06-26 19:28     ` Jeremy Fitzhardinge
2007-06-29  4:13   ` Paul Mackerras
2007-06-29  5:31     ` Jeremy Fitzhardinge
2007-06-29  4:48   ` Paul Mackerras
2007-06-29  5:31     ` Jeremy Fitzhardinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).