From 7ddb295fd0b0dc289b34853c355bae6492797271 Mon Sep 17 00:00:00 2001 From: John Marino Date: Sat, 17 Mar 2012 12:15:04 +0100 Subject: [PATCH] crtstuff: Move ELF note definitions to dedicated header Currently only note.ABI-tag is defined in crt files for the purpose of identifying the operating system and version that created the binary. Soon a new type of note will be created to indicate whether crt is responsible for calling the _init function or not. Creating a separate header avoids duplicate note definitions. --- lib/csu/common/crtbrand.c | 30 ++++++++++++++---------------- lib/csu/common/notes.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 lib/csu/common/notes.h diff --git a/lib/csu/common/crtbrand.c b/lib/csu/common/crtbrand.c index 1d0ddf3eb2..82142a462c 100644 --- a/lib/csu/common/crtbrand.c +++ b/lib/csu/common/crtbrand.c @@ -22,14 +22,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/csu/common/crtbrand.c SVN 217375 2011/01/13 dim $ + * $FreeBSD: src/lib/csu/common/crtbrand.c SVN 232832 2012/03/11 kib $ */ #include - -#define ABI_VENDOR "DragonFly" -#define ABI_SECTION ".note.ABI-tag" -#define ABI_NOTETYPE 1 +#include "notes.h" /* * Special ".note" entry specifying the ABI version. See @@ -54,15 +51,16 @@ * These steps are done in the individual Makefiles for each applicable arch. */ static const struct { - int32_t namesz; - int32_t descsz; - int32_t type; - char name[sizeof ABI_VENDOR]; - int32_t desc; -} abitag __attribute__ ((section (ABI_SECTION))) __attribute__ ((used))= { - sizeof ABI_VENDOR, - sizeof(int32_t), - ABI_NOTETYPE, - ABI_VENDOR, - __DragonFly_version + int32_t namesz; + int32_t descsz; + int32_t type; + char name[sizeof(NOTE_VENDOR)]; + int32_t desc; +} abitag __attribute__ ((section (NOTE_SECTION), + aligned(4))) __attribute__ ((used)) = { + .namesz = sizeof(NOTE_VENDOR), + .descsz = sizeof(int32_t), + .type = ABI_NOTETYPE, + .name = NOTE_VENDOR, + .desc = __DragonFly_version }; diff --git a/lib/csu/common/notes.h b/lib/csu/common/notes.h new file mode 100644 index 0000000000..ff3cf09ef4 --- /dev/null +++ b/lib/csu/common/notes.h @@ -0,0 +1,36 @@ +/*- + * Copyright 2012 Konstantin Belousov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef CSU_COMMON_NOTES_H +#define CSU_COMMON_NOTES_H + +#define NOTE_VENDOR "DragonFly" +#define NOTE_SECTION ".note.ABI-tag" +#define ABI_NOTETYPE 1 +#define CRT_NOINIT_NOTETYPE 0x20 + +#endif -- 2.41.0