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: releng/10.3/lib/csu/common/crtbrand.c 297261 2016-03-25 00:58:15Z marius $"); 28114666Sobrien 2967811Sobrien#include <sys/param.h> 30232832Skib#include "notes.h" 3167811Sobrien 3267811Sobrien/* 3367811Sobrien * Special ".note" entry specifying the ABI version. See 3467811Sobrien * http://www.netbsd.org/Documentation/kernel/elf-notes.html 3567811Sobrien * for more information. 36217375Sdim * 37217375Sdim * For all arches except sparc, gcc emits the section directive for the 38217375Sdim * following struct with a PROGBITS type. However, newer versions of binutils 39217375Sdim * (after 2.16.90) require the section to be of NOTE type, to guarantee that the 40217375Sdim * .note.ABI-tag section correctly ends up in the first page of the final 41217375Sdim * executable. 42217375Sdim * 43217375Sdim * Unfortunately, there is no clean way to tell gcc to use another section type, 44217375Sdim * so this C file (or the C file that includes it) must be compiled in multiple 45217375Sdim * steps: 46217375Sdim * 47217375Sdim * - Compile the .c file to a .s file. 48217375Sdim * - Edit the .s file to change the 'progbits' type to 'note', for the section 49217375Sdim * directive that defines the .note.ABI-tag section. 50217375Sdim * - Compile the .s file to an object file. 51217375Sdim * 52217375Sdim * These steps are done in the invididual Makefiles for each applicable arch. 5367811Sobrien */ 5467811Sobrienstatic const struct { 55232832Skib int32_t namesz; 56232832Skib int32_t descsz; 57232832Skib int32_t type; 58232832Skib char name[sizeof(NOTE_FREEBSD_VENDOR)]; 59232832Skib int32_t desc; 60232832Skib} abitag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = { 61232832Skib .namesz = sizeof(NOTE_FREEBSD_VENDOR), 62232832Skib .descsz = sizeof(int32_t), 63232832Skib .type = ABI_NOTETYPE, 64232832Skib .name = NOTE_FREEBSD_VENDOR, 65297261Smarius .desc = 1003000 6667811Sobrien}; 67