]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - scripts/mod/mk_elfconfig.c
7 main(int argc
, char **argv
)
9 unsigned char ei
[EI_NIDENT
];
10 union { short s
; char c
[2]; } endian_test
;
13 fprintf(stderr
, "Error: no arch\n");
15 if (fread(ei
, 1, EI_NIDENT
, stdin
) != EI_NIDENT
) {
16 fprintf(stderr
, "Error: input truncated\n");
19 if (memcmp(ei
, ELFMAG
, SELFMAG
) != 0) {
20 fprintf(stderr
, "Error: not ELF\n");
23 switch (ei
[EI_CLASS
]) {
25 printf("#define KERNEL_ELFCLASS ELFCLASS32\n");
28 printf("#define KERNEL_ELFCLASS ELFCLASS64\n");
33 switch (ei
[EI_DATA
]) {
35 printf("#define KERNEL_ELFDATA ELFDATA2LSB\n");
38 printf("#define KERNEL_ELFDATA ELFDATA2MSB\n");
44 if (sizeof(unsigned long) == 4) {
45 printf("#define HOST_ELFCLASS ELFCLASS32\n");
46 } else if (sizeof(unsigned long) == 8) {
47 printf("#define HOST_ELFCLASS ELFCLASS64\n");
50 endian_test
.s
= 0x0102;
51 if (memcmp(endian_test
.c
, "\x01\x02", 2) == 0)
52 printf("#define HOST_ELFDATA ELFDATA2MSB\n");
53 else if (memcmp(endian_test
.c
, "\x02\x01", 2) == 0)
54 printf("#define HOST_ELFDATA ELFDATA2LSB\n");
58 if ((strcmp(argv
[1], "v850") == 0) || (strcmp(argv
[1], "h8300") == 0)
59 || (strcmp(argv
[1], "blackfin") == 0))
60 printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
62 printf("#define MODULE_SYMBOL_PREFIX \"\"\n");