Commit be74f368 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Fix kallsyms on 64 bit archs

The generated .tmp_kallsyms.S needs to use .long / .quad for
32/64 bit archs. To know which arch we're compiling for, we
use the preprocessor and BITS_PER_LONG from <asm/types.h>.

Unfortunately, asm/types.h was not safe to include from assembler
files, so lots of #ifndef __ASSEMBLY__ needed to be added - should
be fine now, untested for != i386, though.
parent f5a46614
......@@ -9,6 +9,8 @@
* need to be careful to avoid a name clashes.
*/
#ifndef __ASSEMBLY__
typedef unsigned int umode_t;
/*
......@@ -28,11 +30,17 @@ typedef unsigned int __u32;
typedef __signed__ long __s64;
typedef unsigned long __u64;
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 64
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -45,10 +53,9 @@ typedef unsigned int u32;
typedef signed long s64;
typedef unsigned long u64;
#define BITS_PER_LONG 64
typedef u64 dma_addr_t;
typedef u64 dma64_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _ALPHA_TYPES_H */
#ifndef __ASM_ARM_TYPES_H
#define __ASM_ARM_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -22,11 +24,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -39,13 +47,13 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* Dma addresses are 32-bits wide. */
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
......
#ifndef _ETRAX_TYPES_H
#define _ETRAX_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -22,11 +24,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -39,12 +47,12 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* Dma addresses are 32-bits wide, just like our other addresses. */
typedef u32 dma_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
#ifndef _I386_TYPES_H
#define _I386_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -22,11 +24,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
#include <linux/config.h>
typedef signed char s8;
......@@ -41,8 +49,6 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* DMA addresses come in generic and 64-bit flavours. */
#ifdef CONFIG_HIGHMEM
......@@ -57,6 +63,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
......@@ -14,6 +14,11 @@
#ifdef __ASSEMBLY__
# define __IA64_UL(x) (x)
# define __IA64_UL_CONST(x) x
# ifdef __KERNEL__
# define BITS_PER_LONG 64
# endif
#else
# define __IA64_UL(x) ((unsigned long)(x))
# define __IA64_UL_CONST(x) x##UL
......
......@@ -9,6 +9,8 @@
* need to be careful to avoid a name clashes.
*/
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -30,11 +32,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -47,13 +55,13 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* DMA addresses are always 32-bits wide */
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _M68K_TYPES_H */
......@@ -9,6 +9,8 @@
* need to be careful to avoid a name clashes.
*/
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -30,11 +32,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -47,12 +55,12 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* Dma addresses are 32-bits wide. */
typedef u32 dma_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _M68K_TYPES_H */
......@@ -10,6 +10,8 @@
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -40,11 +42,17 @@ typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG _MIPS_SZLONG
#ifndef __ASSEMBLY__
typedef __signed char s8;
typedef unsigned char u8;
......@@ -68,10 +76,10 @@ typedef unsigned long long u64;
#endif
#define BITS_PER_LONG _MIPS_SZLONG
typedef unsigned long dma_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _ASM_TYPES_H */
......@@ -9,6 +9,8 @@
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned int umode_t;
/*
......@@ -39,11 +41,17 @@ typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG _MIPS_SZLONG
#ifndef __ASSEMBLY__
typedef __signed char s8;
typedef unsigned char u8;
......@@ -67,10 +75,10 @@ typedef unsigned long long u64;
#endif
#define BITS_PER_LONG _MIPS_SZLONG
typedef unsigned long dma_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _ASM_TYPES_H */
#ifndef _PARISC_TYPES_H
#define _PARISC_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -22,11 +24,21 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#ifdef __LP64__
#define BITS_PER_LONG 64
#else
#define BITS_PER_LONG 32
#endif
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -39,17 +51,13 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#ifdef __LP64__
#define BITS_PER_LONG 64
#else
#define BITS_PER_LONG 32
#endif
/* Dma addresses are 32-bits wide. */
typedef u32 dma_addr_t;
typedef u64 dma64_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
......@@ -21,10 +21,22 @@ typedef struct {
__u32 u[4];
} __attribute((aligned(16))) __vector128;
/*
* XXX allowed outside of __KERNEL__ for now, until glibc gets
* a proper set of asm headers of its own. -- paulus
*/
typedef unsigned short umode_t;
#endif /* __ASSEMBLY__ */
#ifdef __KERNEL__
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -39,8 +51,6 @@ typedef unsigned long long u64;
typedef __vector128 vector128;
#define BITS_PER_LONG 32
/* DMA addresses are 32-bits wide */
typedef u32 dma_addr_t;
typedef u64 dma64_addr_t;
......@@ -50,14 +60,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
#endif /* __KERNEL__ */
/*
* XXX allowed outside of __KERNEL__ for now, until glibc gets
* a proper set of asm headers of its own. -- paulus
*/
typedef unsigned short umode_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
......@@ -39,10 +39,16 @@ typedef struct {
__u32 u[4];
} __attribute((aligned(16))) __vector128;
#endif /* __ASSEMBLY__ */
#ifdef __KERNEL__
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#define BITS_PER_LONG 64
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -57,12 +63,11 @@ typedef unsigned long u64;
typedef __vector128 vector128;
#define BITS_PER_LONG 64
typedef u32 dma_addr_t;
typedef u64 dma64_addr_t;
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _PPC64_TYPES_H */
......@@ -9,6 +9,8 @@
#ifndef _S390_TYPES_H
#define _S390_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -34,11 +36,18 @@ typedef unsigned long long __u64;
*/
typedef __u32 addr_t;
typedef __s32 saddr_t;
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -51,8 +60,6 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
typedef u32 dma_addr_t;
typedef union {
......@@ -68,5 +75,7 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
......@@ -9,6 +9,8 @@
#ifndef _S390_TYPES_H
#define _S390_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -36,11 +38,17 @@ typedef unsigned long __u64;
typedef unsigned long addr_t;
typedef signed long saddr_t;
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 64
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -53,9 +61,9 @@ typedef unsigned int u32;
typedef signed long s64;
typedef unsigned long u64;
#define BITS_PER_LONG 64
typedef u32 dma_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
#ifndef __ASM_SH_TYPES_H
#define __ASM_SH_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -22,11 +24,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef __signed__ char s8;
typedef unsigned char u8;
......@@ -39,12 +47,12 @@ typedef unsigned int u32;
typedef __signed__ long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* Dma addresses are 32-bits wide. */
typedef u32 dma_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* __ASM_SH_TYPES_H */
......@@ -15,6 +15,8 @@
* need to be careful to avoid a name clashes.
*/
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
typedef __signed__ char __s8;
......@@ -29,8 +31,14 @@ typedef unsigned int __u32;
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif /* __ASSEMBLY__ */
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef __signed__ char s8;
typedef unsigned char u8;
......@@ -43,11 +51,11 @@ typedef unsigned int u32;
typedef __signed__ long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
typedef u32 dma_addr_t;
typedef u32 dma64_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* defined(_SPARC_TYPES_H) */
......@@ -10,6 +10,8 @@
* need to be careful to avoid a name clashes.
*/
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -29,8 +31,14 @@ typedef unsigned int __u32;
typedef __signed__ long __s64;
typedef unsigned long __u64;
#endif /* __ASSEMBLY__ */
#ifdef __KERNEL__
#define BITS_PER_LONG 64
#ifndef __ASSEMBLY__
typedef __signed__ char s8;
typedef unsigned char u8;
......@@ -43,13 +51,13 @@ typedef unsigned int u32;
typedef __signed__ long s64;
typedef unsigned long u64;
#define BITS_PER_LONG 64
/* Dma addresses come in generic and 64-bit flavours. */
typedef u32 dma_addr_t;
typedef u64 dma64_addr_t;
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* defined(_SPARC64_TYPES_H) */
......@@ -32,11 +32,17 @@ typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif
#endif /* !__ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 32
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -49,14 +55,12 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
/* Dma addresses are 32-bits wide. */
typedef u32 dma_addr_t;
#endif /* __KERNEL__ */
#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* __V850_TYPES_H__ */
#ifndef _X86_64_TYPES_H
#define _X86_64_TYPES_H
#ifndef __ASSEMBLY__
typedef unsigned short umode_t;
/*
......@@ -20,11 +22,17 @@ typedef unsigned int __u32;
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif /* __ASSEMBLY__ */
/*
* These aren't exported outside the kernel to avoid name space clashes
*/
#ifdef __KERNEL__
#define BITS_PER_LONG 64
#ifndef __ASSEMBLY__
typedef signed char s8;
typedef unsigned char u8;
......@@ -37,8 +45,6 @@ typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 64
typedef u64 dma64_addr_t;
typedef u64 dma_addr_t;
......@@ -47,6 +53,8 @@ typedef u64 sector_t;
#define HAVE_SECTOR_T
#endif
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif
......@@ -95,10 +95,19 @@ write_src(void)
int i, valid = 0;
char *prev;
printf("#include <asm/types.h>\n");
printf("#if BITS_PER_LONG == 64\n");
printf("#define PTR .quad\n");
printf("#define ALGN .align 8\n");
printf("#else\n");
printf("#define PTR .long\n");
printf("#define ALGN .align 4\n");
printf("#endif\n");
printf(".data\n");
printf(".globl kallsyms_addresses\n");
printf("\t.align 8\n");
printf("\tALGN\n");
printf("kallsyms_addresses:\n");
for (i = 0, last_addr = 0; i < cnt; i++) {
if (!symbol_valid(&table[i]))
......@@ -107,20 +116,20 @@ write_src(void)
if (table[i].addr == last_addr)
continue;
printf("\t.long\t%#llx\n", table[i].addr);
printf("\tPTR\t%#llx\n", table[i].addr);
valid++;
last_addr = table[i].addr;
}
printf("\n");
printf(".globl kallsyms_num_syms\n");
printf("\t.align 8\n");
printf("\tALGN\n");
printf("kallsyms_num_syms:\n");
printf("\t.long\t%d\n", valid);
printf("\tPTR\t%d\n", valid);
printf("\n");
printf(".globl kallsyms_names\n");
printf("\t.align 8\n");
printf("\tALGN\n");
printf("kallsyms_names:\n");
prev = "";
for (i = 0, last_addr = 0; i < cnt; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment