[Glibc-bsd-commits] r5106 - in trunk/freebsd-glue: debian include/machine src
Robert Millan
rmh at alioth.debian.org
Mon Oct 28 22:09:04 UTC 2013
Author: rmh
Date: 2013-10-28 22:09:03 +0000 (Mon, 28 Oct 2013)
New Revision: 5106
Added:
trunk/freebsd-glue/include/machine/elf.h
trunk/freebsd-glue/src/get_elf_arch.c
Modified:
trunk/freebsd-glue/debian/changelog
trunk/freebsd-glue/debian/rules
Log:
Add <machine/elf.h> (with tricky build magic to generate ELF_ARCH).
Modified: trunk/freebsd-glue/debian/changelog
===================================================================
--- trunk/freebsd-glue/debian/changelog 2013-10-28 22:07:33 UTC (rev 5105)
+++ trunk/freebsd-glue/debian/changelog 2013-10-28 22:09:03 UTC (rev 5106)
@@ -7,6 +7,7 @@
* Move CFLAGS to src/Makefile.
* Expand <sys/elf32.h> and <sys/elf64.h> to support non-kFreeBSD
platforms.
+ * Add <machine/elf.h> (with tricky build magic to generate ELF_ARCH).
-- Robert Millan <rmh at debian.org> Sat, 26 Oct 2013 17:48:31 +0200
Modified: trunk/freebsd-glue/debian/rules
===================================================================
--- trunk/freebsd-glue/debian/rules 2013-10-28 22:07:33 UTC (rev 5105)
+++ trunk/freebsd-glue/debian/rules 2013-10-28 22:09:03 UTC (rev 5106)
@@ -8,10 +8,15 @@
clean:
dh_testdir
$(PMAKE) clean
+ rm -f include/machine/__get_elf_arch.h src/get_elf_arch
dh_clean
+src/get_elf_arch: src/get_elf_arch.c
+include/machine/__get_elf_arch.h: src/get_elf_arch
+ $^ > $@
+
build: build-arch
-build-arch:
+build-arch: include/machine/__get_elf_arch.h
$(PMAKE)
build-indep:
Added: trunk/freebsd-glue/include/machine/elf.h
===================================================================
--- trunk/freebsd-glue/include/machine/elf.h (rev 0)
+++ trunk/freebsd-glue/include/machine/elf.h 2013-10-28 22:09:03 UTC (rev 5106)
@@ -0,0 +1,33 @@
+#ifndef _MACHINE_ELF_H_
+#define _MACHINE_ELF_H_ 1
+
+#include <sys/elf32.h>
+#include <sys/elf64.h>
+
+#ifndef ELF_ARCH
+#include <machine/__get_elf_arch.h> /* ELF_ARCH */
+#endif
+
+#ifndef ELF_TARG_DATA
+#include <endian.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ELF_TARG_DATA ELFDATA2LSB
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define ELF_TARG_DATA ELFDATA2MSB
+#else
+# error wtf??
+#endif
+#endif
+
+#ifndef ELF_TARG_CLASS
+#include <link.h>
+#if __ELF_NATIVE_CLASS == 32
+# define ELF_TARG_CLASS ELFCLASS32
+#elif __ELF_NATIVE_CLASS == 64
+# define ELF_TARG_CLASS ELFCLASS64
+#else
+# error wtf??
+#endif
+#endif
+
+#endif
Added: trunk/freebsd-glue/src/get_elf_arch.c
===================================================================
--- trunk/freebsd-glue/src/get_elf_arch.c (rev 0)
+++ trunk/freebsd-glue/src/get_elf_arch.c 2013-10-28 22:09:03 UTC (rev 5106)
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <elf.h>
+
+int
+main (int argc, char **argv)
+{
+ int fd;
+ Elf32_Ehdr ehdr;
+
+ fd = open (argv[0], O_RDONLY);
+ if (fd == -1)
+ perror ("open");
+
+ if (read (fd, &ehdr, sizeof (ehdr)) != sizeof (ehdr))
+ perror ("read");
+
+ printf ("#define ELF_ARCH %u\n", ehdr.e_machine);
+
+ close (fd);
+}
More information about the Glibc-bsd-commits
mailing list