167811Sobrien/*- 296171Sobrien * Copyright 2000 David E. O'Brien, John D. Polstra. 367811Sobrien * All rights reserved. 467811Sobrien * 567811Sobrien * Redistribution and use in source and binary forms, with or without 667811Sobrien * modification, are permitted provided that the following conditions 767811Sobrien * are met: 867811Sobrien * 1. Redistributions of source code must retain the above copyright 967811Sobrien * notice, this list of conditions and the following disclaimer. 1067811Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1167811Sobrien * notice, this list of conditions and the following disclaimer in the 1267811Sobrien * documentation and/or other materials provided with the distribution. 1367811Sobrien * 1467811Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1567811Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1667811Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1767811Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1867811Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1967811Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2067811Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2167811Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2267811Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2367811Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2467811Sobrien */ 2567811Sobrien 26114666Sobrien#include <sys/cdefs.h> 27114666Sobrien__FBSDID("$FreeBSD$"); 28114666Sobrien 2967811Sobrien#include <sys/param.h> 3067811Sobrien 3167811Sobrien#define ABI_VENDOR "FreeBSD" 3267811Sobrien#define ABI_SECTION ".note.ABI-tag" 3367811Sobrien#define ABI_NOTETYPE 1 3467811Sobrien 3567811Sobrien/* 3667811Sobrien * Special ".note" entry specifying the ABI version. See 3767811Sobrien * http://www.netbsd.org/Documentation/kernel/elf-notes.html 3867811Sobrien * for more information. 39217375Sdim * 40217375Sdim * For all arches except sparc, gcc emits the section directive for the 41217375Sdim * following struct with a PROGBITS type. However, newer versions of binutils 42217375Sdim * (after 2.16.90) require the section to be of NOTE type, to guarantee that the 43217375Sdim * .note.ABI-tag section correctly ends up in the first page of the final 44217375Sdim * executable. 45217375Sdim * 46217375Sdim * Unfortunately, there is no clean way to tell gcc to use another section type, 47217375Sdim * so this C file (or the C file that includes it) must be compiled in multiple 48217375Sdim * steps: 49217375Sdim * 50217375Sdim * - Compile the .c file to a .s file. 51217375Sdim * - Edit the .s file to change the 'progbits' type to 'note', for the section 52217375Sdim * directive that defines the .note.ABI-tag section. 53217375Sdim * - Compile the .s file to an object file. 54217375Sdim * 55217375Sdim * These steps are done in the invididual Makefiles for each applicable arch. 5667811Sobrien */ 5767811Sobrienstatic const struct { 5867811Sobrien int32_t namesz; 5967811Sobrien int32_t descsz; 6067811Sobrien int32_t type; 6167811Sobrien char name[sizeof ABI_VENDOR]; 6267811Sobrien int32_t desc; 63174251Skib} abitag __attribute__ ((section (ABI_SECTION), aligned(4))) __used = { 6467811Sobrien sizeof ABI_VENDOR, 6567811Sobrien sizeof(int32_t), 6667811Sobrien ABI_NOTETYPE, 6767811Sobrien ABI_VENDOR, 68268511Sgjb 903000 6967811Sobrien}; 70