Date: Tue, 9 Jul 2013 09:07:44 +0100 From: Andrew Turner <andrew@fubar.geek.nz> To: freebsd-arch@freebsd.org Subject: Adding a MACHINE_ARCH note Message-ID: <20130709090744.0e497e7e@bender.Home>
next in thread | raw e-mail | index | archive | help
--MP_/cV0SucBe+552YM4Rrf/l/zD
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
I have been looking into an issue where it would be useful to know the
value of MACHINE_ARCH a binary was built with, for example on ARM it
could be arm or armv6 (or the big endian variants).
The reason for this is to teach pkg which arch the package is built for
as there are a few differences between arm and armv6 that mean
an executable built for one may not run on the other.
The attached patch stores the value of MACHINE_ARCH in a note so it can
be read later to get this value. Does anyone have any objections to
this patch, e.g. there is a better way of doing this?
Andrew
--MP_/cV0SucBe+552YM4Rrf/l/zD
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=machine_arch_note.diff
Index: lib/csu/common/crtbrand.c
===================================================================
--- lib/csu/common/crtbrand.c (revision 252514)
+++ lib/csu/common/crtbrand.c (working copy)
@@ -64,3 +64,17 @@
.name = NOTE_FREEBSD_VENDOR,
.desc = __FreeBSD_version
};
+
+static const struct {
+ int32_t namesz;
+ int32_t descsz;
+ int32_t type;
+ char name[sizeof(NOTE_FREEBSD_VENDOR)];
+ char desc[sizeof(MACHINE_ARCH)];
+} archtag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = {
+ .namesz = sizeof(NOTE_FREEBSD_VENDOR),
+ .descsz = sizeof(MACHINE_ARCH),
+ .type = ARCH_NOTETYPE,
+ .name = NOTE_FREEBSD_VENDOR,
+ .desc = MACHINE_ARCH
+};
Index: lib/csu/common/notes.h
===================================================================
--- lib/csu/common/notes.h (revision 252514)
+++ lib/csu/common/notes.h (working copy)
@@ -34,5 +34,6 @@
#define ABI_NOTETYPE 1
#define CRT_NOINIT_NOTETYPE 2
+#define ARCH_NOTETYPE 3
#endif
--MP_/cV0SucBe+552YM4Rrf/l/zD--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130709090744.0e497e7e>
