diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-03-22 18:02:10 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-03-22 18:02:10 +0800 |
commit | b193073d2e5369d848d2135d5a2f642f3242cf0e (patch) | |
tree | d94f5455cc8f1c29348a5564b6b93f2612b9befa /9/platforms/android-19/arch-arm64/usr/include/sys | |
parent | 25ac1196d47cea8ab0d26f6ca692034990f61233 (diff) | |
download | prebuilts_ndk-b193073d2e5369d848d2135d5a2f642f3242cf0e.zip prebuilts_ndk-b193073d2e5369d848d2135d5a2f642f3242cf0e.tar.gz prebuilts_ndk-b193073d2e5369d848d2135d5a2f642f3242cf0e.tar.bz2 |
Update 64-bit headers/libs
Change-Id: I8b1908261c49eafa97f3df174c18b09c1a3d9090
Diffstat (limited to '9/platforms/android-19/arch-arm64/usr/include/sys')
14 files changed, 820 insertions, 1492 deletions
diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/_sigdefs.h b/9/platforms/android-19/arch-arm64/usr/include/sys/_sigdefs.h index eadf7b9..44d60d9 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/_sigdefs.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/_sigdefs.h @@ -35,67 +35,41 @@ #error __BIONIC_SIGDEF not defined #endif -__BIONIC_SIGDEF(HUP,1,"Hangup") -__BIONIC_SIGDEF(INT,2,"Interrupt") -__BIONIC_SIGDEF(QUIT,3,"Quit") -__BIONIC_SIGDEF(ILL,4,"Illegal instruction") -__BIONIC_SIGDEF(TRAP,5,"Trap") -__BIONIC_SIGDEF(ABRT,6,"Aborted") -#ifdef __mips__ -__BIONIC_SIGDEF(EMT,7,"EMT") -#else -__BIONIC_SIGDEF(BUS,7,"Bus error") +__BIONIC_SIGDEF(SIGHUP, "Hangup") +__BIONIC_SIGDEF(SIGINT, "Interrupt") +__BIONIC_SIGDEF(SIGQUIT, "Quit") +__BIONIC_SIGDEF(SIGILL, "Illegal instruction") +__BIONIC_SIGDEF(SIGTRAP, "Trap") +__BIONIC_SIGDEF(SIGABRT, "Aborted") +#ifdef SIGEMT +__BIONIC_SIGDEF(SIGEMT, "EMT") #endif -__BIONIC_SIGDEF(FPE,8,"Floating point exception") -__BIONIC_SIGDEF(KILL,9,"Killed") -#ifdef __mips__ -__BIONIC_SIGDEF(BUS,10,"Bus error") -#else -__BIONIC_SIGDEF(USR1,10,"User signal 1") -#endif -__BIONIC_SIGDEF(SEGV,11,"Segmentation fault") -#ifdef __mips__ -__BIONIC_SIGDEF(SYS,12,"Bad system call") -#else -__BIONIC_SIGDEF(USR2,12,"User signal 2") -#endif -__BIONIC_SIGDEF(PIPE,13,"Broken pipe") -__BIONIC_SIGDEF(ALRM,14,"Alarm clock") -__BIONIC_SIGDEF(TERM,15,"Terminated") -#ifdef __mips__ -__BIONIC_SIGDEF(USR1,16,"User signal 1") -__BIONIC_SIGDEF(USR2,17,"User signal 2") -__BIONIC_SIGDEF(CHLD,18,"Child exited") -__BIONIC_SIGDEF(PWR,19,"Power failure") -__BIONIC_SIGDEF(WINCH,20,"Window size changed") -__BIONIC_SIGDEF(URG,21,"Urgent I/O condition") -__BIONIC_SIGDEF(IO,22,"I/O possible") -__BIONIC_SIGDEF(STOP,23,"Stopped (signal)") -__BIONIC_SIGDEF(TSTP,24,"Stopped") -__BIONIC_SIGDEF(CONT,25,"Continue") -__BIONIC_SIGDEF(TTIN,26,"Stopped (tty input)") -__BIONIC_SIGDEF(TTOU,27,"Stopped (tty output)") -__BIONIC_SIGDEF(VTALRM,28,"Virtual timer expired") -__BIONIC_SIGDEF(PROF,29,"Profiling timer expired") -__BIONIC_SIGDEF(XCPU,30,"CPU time limit exceeded") -__BIONIC_SIGDEF(XFSZ,31,"File size limit exceeded") -#else -__BIONIC_SIGDEF(STKFLT,16,"Stack fault") -__BIONIC_SIGDEF(CHLD,17,"Child exited") -__BIONIC_SIGDEF(CONT,18,"Continue") -__BIONIC_SIGDEF(STOP,19,"Stopped (signal)") -__BIONIC_SIGDEF(TSTP,20,"Stopped") -__BIONIC_SIGDEF(TTIN,21,"Stopped (tty input)") -__BIONIC_SIGDEF(TTOU,22,"Stopped (tty output)") -__BIONIC_SIGDEF(URG,23,"Urgent I/O condition") -__BIONIC_SIGDEF(XCPU,24,"CPU time limit exceeded") -__BIONIC_SIGDEF(XFSZ,25,"File size limit exceeded") -__BIONIC_SIGDEF(VTALRM,26,"Virtual timer expired") -__BIONIC_SIGDEF(PROF,27,"Profiling timer expired") -__BIONIC_SIGDEF(WINCH,28,"Window size changed") -__BIONIC_SIGDEF(IO,29,"I/O possible") -__BIONIC_SIGDEF(PWR,30,"Power failure") -__BIONIC_SIGDEF(SYS,31,"Bad system call") +__BIONIC_SIGDEF(SIGFPE, "Floating point exception") +__BIONIC_SIGDEF(SIGKILL, "Killed") +__BIONIC_SIGDEF(SIGBUS, "Bus error") +__BIONIC_SIGDEF(SIGSEGV, "Segmentation fault") +__BIONIC_SIGDEF(SIGPIPE, "Broken pipe") +__BIONIC_SIGDEF(SIGALRM, "Alarm clock") +__BIONIC_SIGDEF(SIGTERM, "Terminated") +__BIONIC_SIGDEF(SIGUSR1, "User signal 1") +__BIONIC_SIGDEF(SIGUSR2, "User signal 2") +__BIONIC_SIGDEF(SIGCHLD, "Child exited") +__BIONIC_SIGDEF(SIGPWR, "Power failure") +__BIONIC_SIGDEF(SIGWINCH, "Window size changed") +__BIONIC_SIGDEF(SIGURG, "Urgent I/O condition") +__BIONIC_SIGDEF(SIGIO, "I/O possible") +__BIONIC_SIGDEF(SIGSTOP, "Stopped (signal)") +__BIONIC_SIGDEF(SIGTSTP, "Stopped") +__BIONIC_SIGDEF(SIGCONT, "Continue") +__BIONIC_SIGDEF(SIGTTIN, "Stopped (tty input)") +__BIONIC_SIGDEF(SIGTTOU, "Stopped (tty output)") +__BIONIC_SIGDEF(SIGVTALRM, "Virtual timer expired") +__BIONIC_SIGDEF(SIGPROF, "Profiling timer expired") +__BIONIC_SIGDEF(SIGXCPU, "CPU time limit exceeded") +__BIONIC_SIGDEF(SIGXFSZ, "File size limit exceeded") +#if defined(SIGSTKFLT) +__BIONIC_SIGDEF(SIGSTKFLT, "Stack fault") #endif +__BIONIC_SIGDEF(SIGSYS, "Bad system call") #undef __BIONIC_SIGDEF diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/_system_properties.h b/9/platforms/android-19/arch-arm64/usr/include/sys/_system_properties.h index 5eee7f0..5a681df 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/_system_properties.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/_system_properties.h @@ -139,6 +139,14 @@ int __system_property_foreach_compat( void (*propfn)(const prop_info *pi, void *cookie), void *cookie); +/* Initialize the system properties area in read only mode. + * Should be done by all processes that need to read system + * properties. + * + * Returns 0 on success, -1 otherwise. + */ +int __system_properties_init(); + __END_DECLS #endif diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/_types.h b/9/platforms/android-19/arch-arm64/usr/include/sys/_types.h index 6bf9c1c..7b99e06 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/_types.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/_types.h @@ -32,50 +32,15 @@ */ #ifndef _SYS__TYPES_H_ -#define _SYS__TYPES_H_ +#define _SYS__TYPES_H_ -typedef __signed char __int8_t; -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -#if __LP64__ -typedef long __int64_t; -typedef unsigned long __uint64_t; -#else -typedef long long __int64_t; -typedef unsigned long long __uint64_t; -#endif +#undef __KERNEL_STRICT_NAMES +#define __KERNEL_STRICT_NAMES 1 -#if __LP64__ -typedef long __intptr_t; -typedef unsigned long __uintptr_t; -#else -typedef int __intptr_t; -typedef unsigned int __uintptr_t; -#endif - -#if __LP64__ -typedef long __time_t; -#else -typedef int __time_t; /* Historical accident. */ -#endif - -typedef int __timer_t; - -typedef int __clockid_t; - -#ifndef __cplusplus -typedef int __wchar_t; -#endif - -typedef double __double_t; -typedef float __float_t; - -typedef __builtin_va_list __va_list; +#include <machine/_types.h> typedef unsigned long __cpuid_t; /* CPU id */ +typedef __int32_t __dev_t; /* device number */ typedef __uint32_t __fixpt_t; /* fixed point number */ typedef __uint32_t __gid_t; /* group id */ typedef __uint32_t __id_t; /* may contain pid, uid or gid */ @@ -104,4 +69,9 @@ typedef union { __int64_t __mbstateL; /* for alignment */ } __mbstate_t; +/* BIONIC: if we're using non-cleaned up user-level kernel headers, + * this will prevent many type declaration conflicts + */ +#define __KERNEL_STRICT_NAMES 1 + #endif /* !_SYS__TYPES_H_ */ diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/exec_elf.h b/9/platforms/android-19/arch-arm64/usr/include/sys/exec_elf.h index d14c596..f72f81e 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/exec_elf.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/exec_elf.h @@ -1,11 +1,6 @@ -/* $NetBSD: exec_elf.h,v 1.131 2013/10/29 00:22:59 christos Exp $ */ - -/*- - * Copyright (c) 1994 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. +/* $OpenBSD: exec_elf.h,v 1.41 2006/01/06 18:53:05 millert Exp $ */ +/* + * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -15,164 +10,101 @@ * 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. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``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 FOUNDATION OR CONTRIBUTORS - * 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. + * 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. + */ + +/* + * This is the ELF ABI header file + * formerly known as "elf_abi.h". */ #ifndef _SYS_EXEC_ELF_H_ #define _SYS_EXEC_ELF_H_ -/* - * The current ELF ABI specification is available at: - * http://www.sco.com/developers/gabi/ - * - * Current header definitions are in: - * http://www.sco.com/developers/gabi/latest/ch4.eheader.html - */ +#include <machine/_types.h> +#include <machine/exec.h> -#if defined(_KERNEL) || defined(_STANDALONE) -#include <sys/types.h> -#else -#include <inttypes.h> -#endif /* _KERNEL || _STANDALONE */ +typedef __uint8_t Elf_Byte; -#if HAVE_NBTOOL_CONFIG_H -#include <nbinclude/machine/elf_machdep.h> +typedef __uint32_t Elf32_Addr; /* Unsigned program address */ +typedef __uint32_t Elf32_Off; /* Unsigned file offset */ +typedef __int32_t Elf32_Sword; /* Signed large integer */ +typedef __uint32_t Elf32_Word; /* Unsigned large integer */ +typedef __uint16_t Elf32_Half; /* Unsigned medium integer */ + +typedef __uint64_t Elf64_Addr; +typedef __uint64_t Elf64_Off; +typedef __int32_t Elf64_Shalf; + +#ifdef __alpha__ +typedef __int64_t Elf64_Sword; +typedef __uint64_t Elf64_Word; #else -#include <machine/elf_machdep.h> +typedef __int32_t Elf64_Sword; +typedef __uint32_t Elf64_Word; #endif -typedef uint8_t Elf_Byte; - -typedef uint32_t Elf32_Addr; -#define ELF32_FSZ_ADDR 4 -typedef uint32_t Elf32_Off; -typedef int32_t Elf32_SOff; -#define ELF32_FSZ_OFF 4 -typedef int32_t Elf32_Sword; -#define ELF32_FSZ_SWORD 4 -typedef uint32_t Elf32_Word; -#define ELF32_FSZ_WORD 4 -typedef uint16_t Elf32_Half; -#define ELF32_FSZ_HALF 2 -typedef uint64_t Elf32_Lword; -#define ELF32_FSZ_LWORD 8 - -typedef uint64_t Elf64_Addr; -#define ELF64_FSZ_ADDR 8 -typedef uint64_t Elf64_Off; -typedef int64_t Elf64_SOff; -#define ELF64_FSZ_OFF 8 -typedef int32_t Elf64_Shalf; -#define ELF64_FSZ_SHALF 4 - -typedef int32_t Elf64_Sword; -#define ELF64_FSZ_SWORD 4 -typedef uint32_t Elf64_Word; -#define ELF64_FSZ_WORD 4 - -typedef int64_t Elf64_Sxword; -#define ELF64_FSZ_SXWORD 8 -typedef uint64_t Elf64_Xword; -#define ELF64_FSZ_XWORD 8 -typedef uint64_t Elf64_Lword; -#define ELF64_FSZ_LWORD 8 -typedef uint16_t Elf64_Half; -#define ELF64_FSZ_HALF 2 +typedef __int64_t Elf64_Sxword; +typedef __uint64_t Elf64_Xword; + +typedef __uint32_t Elf64_Half; +typedef __uint16_t Elf64_Quarter; /* - * ELF Header + * e_ident[] identification indexes + * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html */ -#define ELF_NIDENT 16 - -typedef struct { - unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ - Elf32_Half e_type; /* file type */ - Elf32_Half e_machine; /* machine type */ - Elf32_Word e_version; /* version number */ - Elf32_Addr e_entry; /* entry point */ - Elf32_Off e_phoff; /* Program hdr offset */ - Elf32_Off e_shoff; /* Section hdr offset */ - Elf32_Word e_flags; /* Processor flags */ - Elf32_Half e_ehsize; /* sizeof ehdr */ - Elf32_Half e_phentsize; /* Program header entry size */ - Elf32_Half e_phnum; /* Number of program headers */ - Elf32_Half e_shentsize; /* Section header entry size */ - Elf32_Half e_shnum; /* Number of section headers */ - Elf32_Half e_shstrndx; /* String table index */ -} Elf32_Ehdr; - -typedef struct { - unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ - Elf64_Half e_type; /* file type */ - Elf64_Half e_machine; /* machine type */ - Elf64_Word e_version; /* version number */ - Elf64_Addr e_entry; /* entry point */ - Elf64_Off e_phoff; /* Program hdr offset */ - Elf64_Off e_shoff; /* Section hdr offset */ - Elf64_Word e_flags; /* Processor flags */ - Elf64_Half e_ehsize; /* sizeof ehdr */ - Elf64_Half e_phentsize; /* Program header entry size */ - Elf64_Half e_phnum; /* Number of program headers */ - Elf64_Half e_shentsize; /* Section header entry size */ - Elf64_Half e_shnum; /* Number of section headers */ - Elf64_Half e_shstrndx; /* String table index */ -} Elf64_Ehdr; - -/* e_ident offsets */ -#define EI_MAG0 0 /* '\177' */ -#define EI_MAG1 1 /* 'E' */ -#define EI_MAG2 2 /* 'L' */ -#define EI_MAG3 3 /* 'F' */ -#define EI_CLASS 4 /* File class */ -#define EI_DATA 5 /* Data encoding */ -#define EI_VERSION 6 /* File version */ -#define EI_OSABI 7 /* Operating system/ABI identification */ -#define EI_ABIVERSION 8 /* ABI version */ -#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ -#define EI_NIDENT 16 /* First non-ident header byte */ - -/* e_ident[EI_MAG0,EI_MAG3] */ -#define ELFMAG0 0x7f -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -/* e_ident[EI_CLASS] */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -/* e_ident[EI_DATA] */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ -#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ - -/* e_ident[EI_VERSION] */ -#define EV_NONE 0 /* Invalid version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -/* e_ident[EI_OSABI] */ +#define EI_MAG0 0 /* file ID */ +#define EI_MAG1 1 /* file ID */ +#define EI_MAG2 2 /* file ID */ +#define EI_MAG3 3 /* file ID */ +#define EI_CLASS 4 /* file class */ +#define EI_DATA 5 /* data encoding */ +#define EI_VERSION 6 /* ELF header version */ +#define EI_OSABI 7 /* OS/ABI ID */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* start of pad bytes */ +#define EI_NIDENT 16 /* Size of e_ident[] */ + +/* e_ident[] magic number */ +#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ +#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ +#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ +#define ELFMAG3 'F' /* e_ident[EI_MAG3] */ +#define ELFMAG "\177ELF" /* magic */ +#define SELFMAG 4 /* size of magic */ + +/* e_ident[] file class */ +#define ELFCLASSNONE 0 /* invalid */ +#define ELFCLASS32 1 /* 32-bit objs */ +#define ELFCLASS64 2 /* 64-bit objs */ +#define ELFCLASSNUM 3 /* number of classes */ + +/* e_ident[] data encoding */ +#define ELFDATANONE 0 /* invalid */ +#define ELFDATA2LSB 1 /* Little-Endian */ +#define ELFDATA2MSB 2 /* Big-Endian */ +#define ELFDATANUM 3 /* number of data encode defines */ + +/* e_ident[] Operating System/ABI */ #define ELFOSABI_SYSV 0 /* UNIX System V ABI */ #define ELFOSABI_HPUX 1 /* HP-UX operating system */ #define ELFOSABI_NETBSD 2 /* NetBSD */ #define ELFOSABI_LINUX 3 /* GNU/Linux */ #define ELFOSABI_HURD 4 /* GNU/Hurd */ -#define ELFOSABI_86OPEN 5 /* 86Open */ +#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ #define ELFOSABI_SOLARIS 6 /* Solaris */ #define ELFOSABI_MONTEREY 7 /* Monterey */ #define ELFOSABI_IRIX 8 /* IRIX */ @@ -180,832 +112,421 @@ typedef struct { #define ELFOSABI_TRU64 10 /* TRU64 UNIX */ #define ELFOSABI_MODESTO 11 /* Novell Modesto */ #define ELFOSABI_OPENBSD 12 /* OpenBSD */ -#define ELFOSABI_OPENVMS 13 /* OpenVMS */ -#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ -#define ELFOSABI_AROS 15 /* Amiga Research OS */ -/* Unofficial OSABIs follow */ #define ELFOSABI_ARM 97 /* ARM */ #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ -#define ELFOSABI_NONE ELFOSABI_SYSV -#define ELFOSABI_AIX ELFOSABI_MONTEREY - -/* e_type */ -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 - -#define ET_LOOS 0xfe00 /* Operating system specific range */ -#define ET_HIOS 0xfeff -#define ET_LOPROC 0xff00 /* Processor-specific range */ -#define ET_HIPROC 0xffff - -/* e_machine */ -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola 68000 */ -#define EM_88K 5 /* Motorola 88000 */ -#define EM_486 6 /* Intel 80486 */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS I Architecture */ -#define EM_S370 9 /* Amdahl UTS on System/370 */ -#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ - /* 11-14 - Reserved */ -#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ -#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ -#define EM_NCUBE 16 /* NCube XXX reserved */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* 64-bit PowerPC */ - /* 22-35 - Reserved */ -#define EM_S390 22 /* System/390 XXX reserved */ -#define EM_V800 36 /* NEC V800 */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* Advanced RISC Machines ARM */ -#define EM_ALPHA 41 /* DIGITAL Alpha */ -#define EM_SH 42 /* Hitachi Super-H */ -#define EM_SPARCV9 43 /* SPARC Version 9 */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced Processor */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola MC68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Star*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronics ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ -#define EM_X86_64 62 /* AMD x86-64 architecture */ -#define EM_PDSP 63 /* Sony DSP Processor */ -#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ -#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ -#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ -#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ -#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ -#define EM_HUANY 81 /* Harvard's machine-independent format */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi D10V */ -#define EM_D30V 86 /* Mitsubishi D30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10300 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ -#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ -#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ -#define EM_NS32K 97 /* National Semiconductor 32000 series */ -#define EM_TPC 98 /* Tenor Network TPC processor */ -#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ -#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ -#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ -#define EM_MAX 102 /* MAX processor */ -#define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ -#define EM_F2MC16 104 /* Fujitsu F2MC16 */ -#define EM_MSP430 105 /* Texas Instruments MSP430 */ -#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ -#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ -#define EM_SEP 108 /* Sharp embedded microprocessor */ -#define EM_ARCA 109 /* Arca RISC microprocessor */ -#define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ -#define EM_AARCH64 183 /* AArch64 64-bit ARM microprocessor */ - -/* Unofficial machine types follow */ -#define EM_AVR32 6317 /* used by NetBSD/avr32 */ -#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ -#define EM_NUM 36903 - -/* - * Program Header - */ -typedef struct { - Elf32_Word p_type; /* entry type */ - Elf32_Off p_offset; /* offset */ - Elf32_Addr p_vaddr; /* virtual address */ - Elf32_Addr p_paddr; /* physical address */ - Elf32_Word p_filesz; /* file size */ - Elf32_Word p_memsz; /* memory size */ - Elf32_Word p_flags; /* flags */ - Elf32_Word p_align; /* memory & file alignment */ -} Elf32_Phdr; +/* e_ident */ +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ + (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ + (ehdr).e_ident[EI_MAG3] == ELFMAG3) + +/* ELF Header */ +typedef struct elfhdr { + unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ + Elf32_Half e_type; /* object file type */ + Elf32_Half e_machine; /* machine */ + Elf32_Word e_version; /* object file version */ + Elf32_Addr e_entry; /* virtual entry point */ + Elf32_Off e_phoff; /* program header table offset */ + Elf32_Off e_shoff; /* section header table offset */ + Elf32_Word e_flags; /* processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size */ + Elf32_Half e_phentsize; /* program header entry size */ + Elf32_Half e_phnum; /* number of program header entries */ + Elf32_Half e_shentsize; /* section header entry size */ + Elf32_Half e_shnum; /* number of section header entries */ + Elf32_Half e_shstrndx; /* section header table's "section + header string table" entry offset */ +} Elf32_Ehdr; typedef struct { - Elf64_Word p_type; /* entry type */ - Elf64_Word p_flags; /* flags */ - Elf64_Off p_offset; /* offset */ - Elf64_Addr p_vaddr; /* virtual address */ - Elf64_Addr p_paddr; /* physical address */ - Elf64_Xword p_filesz; /* file size */ - Elf64_Xword p_memsz; /* memory size */ - Elf64_Xword p_align; /* memory & file alignment */ -} Elf64_Phdr; - -/* p_type */ -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved, unspecified semantics */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_TLS 7 /* TLS initialisation image */ -#define PT_NUM 8 - -#define PT_LOOS 0x60000000 /* OS-specific range */ - -/* GNU-specific */ -#define PT_GNU_EH_FRAME 0x6474e550 /* EH frame segment */ -#define PT_GNU_STACK 0x6474e551 /* Indicate executable stack */ -#define PT_GNU_RELRO 0x6474e552 /* Make read-only after relocation */ - -#define PT_HIOS 0x6fffffff -#define PT_LOPROC 0x70000000 /* Processor-specific range */ -#define PT_HIPROC 0x7fffffff - -#define PT_MIPS_REGINFO 0x70000000 - -/* p_flags */ -#define PF_R 0x4 /* Segment is readable */ -#define PF_W 0x2 /* Segment is writable */ -#define PF_X 0x1 /* Segment is executable */ - -#define PF_MASKOS 0x0ff00000 /* Operating system specific values */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ + unsigned char e_ident[EI_NIDENT]; /* Id bytes */ + Elf64_Quarter e_type; /* file type */ + Elf64_Quarter e_machine; /* machine type */ + Elf64_Half e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Half e_flags; /* Processor flags */ + Elf64_Quarter e_ehsize; /* sizeof ehdr */ + Elf64_Quarter e_phentsize; /* Program header entry size */ + Elf64_Quarter e_phnum; /* Number of program headers */ + Elf64_Quarter e_shentsize; /* Section header entry size */ + Elf64_Quarter e_shnum; /* Number of section headers */ + Elf64_Quarter e_shstrndx; /* String table index */ +} Elf64_Ehdr; -/* Extended program header index. */ -#define PN_XNUM 0xffff +/* e_type */ +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* relocatable file */ +#define ET_EXEC 2 /* executable file */ +#define ET_DYN 3 /* shared object file */ +#define ET_CORE 4 /* core file */ +#define ET_NUM 5 /* number of types */ +#define ET_LOPROC 0xff00 /* reserved range for processor */ +#define ET_HIPROC 0xffff /* specific e_type */ -/* - * Section Headers +/* e_machine */ +#define EM_NONE 0 /* No Machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 - unused? */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ +/* + * Don't know if EM_MIPS_RS4_BE, + * EM_SPARC64, EM_PARISC, + * or EM_PPC are ABI compliant */ +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ +#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */ +#define EM_PARISC 15 /* HPPA */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_PPC 20 /* PowerPC */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_ALPHA 41 /* DEC ALPHA */ +#define EM_SPARCV9 43 /* SPARC version 9 */ +#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */ +#define EM_AMD64 62 /* AMD64 architecture */ +#define EM_VAX 75 /* DEC VAX */ +#define EM_NUM 15 /* number of machine types */ + +/* Version */ +#define EV_NONE 0 /* Invalid */ +#define EV_CURRENT 1 /* Current */ +#define EV_NUM 2 /* number of versions */ + +/* Section Header */ typedef struct { - Elf32_Word sh_name; /* section name (.shstrtab index) */ - Elf32_Word sh_type; /* section type */ - Elf32_Word sh_flags; /* section flags */ - Elf32_Addr sh_addr; /* virtual address */ + Elf32_Word sh_name; /* name - index into section header + string table section */ + Elf32_Word sh_type; /* type */ + Elf32_Word sh_flags; /* flags */ + Elf32_Addr sh_addr; /* address */ Elf32_Off sh_offset; /* file offset */ Elf32_Word sh_size; /* section size */ - Elf32_Word sh_link; /* link to another */ - Elf32_Word sh_info; /* misc info */ - Elf32_Word sh_addralign; /* memory alignment */ - Elf32_Word sh_entsize; /* table entry size */ + Elf32_Word sh_link; /* section header table index link */ + Elf32_Word sh_info; /* extra information */ + Elf32_Word sh_addralign; /* address alignment */ + Elf32_Word sh_entsize; /* section entry size */ } Elf32_Shdr; typedef struct { - Elf64_Word sh_name; /* section name (.shstrtab index) */ - Elf64_Word sh_type; /* section type */ + Elf64_Half sh_name; /* section name */ + Elf64_Half sh_type; /* section type */ Elf64_Xword sh_flags; /* section flags */ Elf64_Addr sh_addr; /* virtual address */ Elf64_Off sh_offset; /* file offset */ Elf64_Xword sh_size; /* section size */ - Elf64_Word sh_link; /* link to another */ - Elf64_Word sh_info; /* misc info */ + Elf64_Half sh_link; /* link to another */ + Elf64_Half sh_info; /* misc info */ Elf64_Xword sh_addralign; /* memory alignment */ Elf64_Xword sh_entsize; /* table entry size */ } Elf64_Shdr; +/* Special Section Indexes */ +#define SHN_UNDEF 0 /* undefined */ +#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ +#define SHN_LOPROC 0xff00 /* reserved range for processor */ +#define SHN_HIPROC 0xff1f /* specific section indexes */ +#define SHN_ABS 0xfff1 /* absolute value */ +#define SHN_COMMON 0xfff2 /* common symbol */ +#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ + /* sh_type */ -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program information */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation information w/ addend */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Dynamic linking information */ -#define SHT_NOTE 7 /* Auxiliary information */ -#define SHT_NOBITS 8 /* No space allocated in file image */ -#define SHT_REL 9 /* Relocation information w/o addend */ -#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ -#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ -#define SHT_INIT_ARRAY 14 /* Initialization function pointers */ -#define SHT_FINI_ARRAY 15 /* Termination function pointers */ -#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ -#define SHT_NUM 19 - -#define SHT_LOOS 0x60000000 /* Operating system specific range */ -#define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ -#define SHT_GNU_verdef SHT_SUNW_verdef -#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ -#define SHT_GNU_verneed SHT_SUNW_verneed -#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ -#define SHT_GNU_versym SHT_SUNW_versym -#define SHT_HIOS 0x6fffffff -#define SHT_LOPROC 0x70000000 /* Processor-specific range */ -#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ -#define SHT_ARM_EXIDX 0x70000001 /* exception index table */ -#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking - * pre-emption map */ -#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility - * attributes */ -#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details */ -#define SHT_ARM_OVERLAYSECTION 0x70000005 -#define SHT_HIPROC 0x7fffffff -#define SHT_LOUSER 0x80000000 /* Application-specific range */ -#define SHT_HIUSER 0xffffffff - -/* sh_flags */ -#define SHF_WRITE 0x00000001 /* Contains writable data */ -#define SHF_ALLOC 0x00000002 /* Occupies memory */ -#define SHF_EXECINSTR 0x00000004 /* Contains executable insns */ -#define SHF_MERGE 0x00000010 /* Might be merged */ -#define SHF_STRINGS 0x00000020 /* Contains nul terminated strings */ -#define SHF_INFO_LINK 0x00000040 /* "sh_info" contains SHT index */ -#define SHF_LINK_ORDER 0x00000080 /* Preserve order after combining */ -#define SHF_OS_NONCONFORMING 0x00000100 /* OS specific handling required */ -#define SHF_GROUP 0x00000200 /* Is member of a group */ -#define SHF_TLS 0x00000400 /* Holds thread-local data */ -#define SHF_MASKOS 0x0ff00000 /* Operating system specific values */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ -#define SHF_ORDERED 0x40000000 /* Ordering requirement (Solaris) */ -#define SHF_EXCLUDE 0x80000000 /* Excluded unless unles ref/alloc - (Solaris).*/ -/* - * Symbol Table - */ -typedef struct { - Elf32_Word st_name; /* Symbol name (.strtab index) */ - Elf32_Word st_value; /* value of symbol */ - Elf32_Word st_size; /* size of symbol */ - Elf_Byte st_info; /* type / binding attrs */ - Elf_Byte st_other; /* unused */ - Elf32_Half st_shndx; /* section index of symbol */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined information */ +#define SHT_SYMTAB 2 /* symbol table section */ +#define SHT_STRTAB 3 /* string table section */ +#define SHT_RELA 4 /* relocation section with addends*/ +#define SHT_HASH 5 /* symbol hash table section */ +#define SHT_DYNAMIC 6 /* dynamic section */ +#define SHT_NOTE 7 /* note section */ +#define SHT_NOBITS 8 /* no space section */ +#define SHT_REL 9 /* relation section without addends */ +#define SHT_SHLIB 10 /* reserved - purpose unknown */ +#define SHT_DYNSYM 11 /* dynamic symbol table section */ +#define SHT_NUM 12 /* number of section types */ +#define SHT_LOPROC 0x70000000 /* reserved range for processor */ +#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_LOUSER 0x80000000 /* reserved range for application */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ + +/* Section names */ +#define ELF_BSS ".bss" /* uninitialized data */ +#define ELF_DATA ".data" /* initialized data */ +#define ELF_DEBUG ".debug" /* debug */ +#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ +#define ELF_DYNSTR ".dynstr" /* dynamic string table */ +#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ +#define ELF_FINI ".fini" /* termination code */ +#define ELF_GOT ".got" /* global offset table */ +#define ELF_HASH ".hash" /* symbol hash table */ +#define ELF_INIT ".init" /* initialization code */ +#define ELF_REL_DATA ".rel.data" /* relocation data */ +#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ +#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ +#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ +#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ +#define ELF_REL_TEXT ".rel.text" /* relocation code */ +#define ELF_RODATA ".rodata" /* read-only data */ +#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ +#define ELF_STRTAB ".strtab" /* string table */ +#define ELF_SYMTAB ".symtab" /* symbol table */ +#define ELF_TEXT ".text" /* code */ + + +/* Section Attribute Flags - sh_flags */ +#define SHF_WRITE 0x1 /* Writable */ +#define SHF_ALLOC 0x2 /* occupies memory */ +#define SHF_EXECINSTR 0x4 /* executable */ +#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ + /* specific section attributes */ + +/* Symbol Table Entry */ +typedef struct elf32_sym { + Elf32_Word st_name; /* name - index into string table */ + Elf32_Addr st_value; /* symbol value */ + Elf32_Word st_size; /* symbol size */ + unsigned char st_info; /* type and binding */ + unsigned char st_other; /* 0 - no defined meaning */ + Elf32_Half st_shndx; /* section header index */ } Elf32_Sym; typedef struct { - Elf64_Word st_name; /* Symbol name (.strtab index) */ + Elf64_Half st_name; /* Symbol name index in str table */ Elf_Byte st_info; /* type / binding attrs */ Elf_Byte st_other; /* unused */ - Elf64_Half st_shndx; /* section index of symbol */ - Elf64_Addr st_value; /* value of symbol */ + Elf64_Quarter st_shndx; /* section index of symbol */ + Elf64_Xword st_value; /* value of symbol */ Elf64_Xword st_size; /* size of symbol */ } Elf64_Sym; -/* Symbol Table index of the undefined symbol */ -#define ELF_SYM_UNDEFINED 0 - -#define STN_UNDEF 0 /* undefined index */ - -/* st_info: Symbol Bindings */ -#define STB_LOCAL 0 /* local symbol */ -#define STB_GLOBAL 1 /* global symbol */ -#define STB_WEAK 2 /* weakly defined global symbol */ -#define STB_NUM 3 - -#define STB_LOOS 10 /* Operating system specific range */ -#define STB_HIOS 12 -#define STB_LOPROC 13 /* Processor-specific range */ -#define STB_HIPROC 15 - -/* st_info: Symbol Types */ -#define STT_NOTYPE 0 /* Type not specified */ -#define STT_OBJECT 1 /* Associated with a data object */ -#define STT_FUNC 2 /* Associated with a function */ -#define STT_SECTION 3 /* Associated with a section */ -#define STT_FILE 4 /* Associated with a file name */ -#define STT_COMMON 5 /* Uninitialised common block */ -#define STT_TLS 6 /* Thread local data object */ -#define STT_NUM 7 - -#define STT_LOOS 10 /* Operating system specific range */ -#define STT_HIOS 12 -#define STT_LOPROC 13 /* Processor-specific range */ -#define STT_HIPROC 15 - -/* st_other: Visibility Types */ -#define STV_DEFAULT 0 /* use binding type */ -#define STV_INTERNAL 1 /* not referenced from outside */ -#define STV_HIDDEN 2 /* not visible, may be used via ptr */ -#define STV_PROTECTED 3 /* visible, not preemptible */ -#define STV_EXPORTED 4 -#define STV_SINGLETON 5 -#define STV_ELIMINATE 6 - -/* st_info/st_other utility macros */ -#define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) -#define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) -#define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ - ((type) & 0xf))) -#define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) - -/* - * Special section indexes - */ -#define SHN_UNDEF 0 /* Undefined section */ - -#define SHN_LORESERVE 0xff00 /* Reserved range */ -#define SHN_ABS 0xfff1 /* Absolute symbols */ -#define SHN_COMMON 0xfff2 /* Common symbols */ -#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ -#define SHN_HIRESERVE 0xffff - -#define SHN_LOPROC 0xff00 /* Processor-specific range */ -#define SHN_HIPROC 0xff1f -#define SHN_LOOS 0xff20 /* Operating system specific range */ -#define SHN_HIOS 0xff3f - -#define SHN_MIPS_ACOMMON 0xff00 -#define SHN_MIPS_TEXT 0xff01 -#define SHN_MIPS_DATA 0xff02 -#define SHN_MIPS_SCOMMON 0xff03 - -/* - * Relocation Entries - */ +/* Symbol table index */ +#define STN_UNDEF 0 /* undefined */ + +/* Extract symbol info - st_info */ +#define ELF32_ST_BIND(x) ((x) >> 4) +#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) +#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) + +#define ELF64_ST_BIND(x) ((x) >> 4) +#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf) +#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) + +/* Symbol Binding - ELF32_ST_BIND - st_info */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* like global - lower precedence */ +#define STB_NUM 3 /* number of symbol bindings */ +#define STB_LOPROC 13 /* reserved range for processor */ +#define STB_HIPROC 15 /* specific symbol bindings */ + +/* Symbol type - ELF32_ST_TYPE - st_info */ +#define STT_NOTYPE 0 /* not specified */ +#define STT_OBJECT 1 /* data object */ +#define STT_FUNC 2 /* function */ +#define STT_SECTION 3 /* section */ +#define STT_FILE 4 /* file */ +#define STT_NUM 5 /* number of symbol types */ +#define STT_LOPROC 13 /* reserved range for processor */ +#define STT_HIPROC 15 /* specific symbol types */ + +/* Relocation entry with implicit addend */ typedef struct { - Elf32_Word r_offset; /* where to do it */ - Elf32_Word r_info; /* index & type of relocation */ + Elf32_Addr r_offset; /* offset of relocation */ + Elf32_Word r_info; /* symbol table index and type */ } Elf32_Rel; +/* Relocation entry with explicit addend */ typedef struct { - Elf32_Word r_offset; /* where to do it */ - Elf32_Word r_info; /* index & type of relocation */ - Elf32_Sword r_addend; /* adjustment value */ + Elf32_Addr r_offset; /* offset of relocation */ + Elf32_Word r_info; /* symbol table index and type */ + Elf32_Sword r_addend; } Elf32_Rela; -/* r_info utility macros */ -#define ELF32_R_SYM(info) ((info) >> 8) -#define ELF32_R_TYPE(info) ((info) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) +/* Extract relocation info - r_info */ +#define ELF32_R_SYM(i) ((i) >> 8) +#define ELF32_R_TYPE(i) ((unsigned char) (i)) +#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) typedef struct { - Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_offset; /* where to do it */ Elf64_Xword r_info; /* index & type of relocation */ } Elf64_Rel; typedef struct { - Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_offset; /* where to do it */ Elf64_Xword r_info; /* index & type of relocation */ Elf64_Sxword r_addend; /* adjustment value */ } Elf64_Rela; -/* r_info utility macros */ -#if defined(__mips__) -#if defined(__MIPSEL__) -#define ELF64_R_SYM(info) (((info) >> 0) & 0xffffffff) -#define ELF64_R_SSYM(info) (((info) >> 32) & 0xff) -#define ELF64_R_TYPE3(info) (((info) >> 40) & 0xff) -#define ELF64_R_TYPE2(info) (((info) >> 48) & 0xff) -#define ELF64_R_TYPE(info) (((info) >> 56) & 0xff) -#define ELF64_R_INFO(sym,ssym,type,type2,type3) \ - (((type) << 56) + ((type2) << 48) + ((type3) << 40) + ((ssym) << 32) + (sym)) -#else -#define ELF64_R_SYM(info) (((info) >> 32) & 0xffffffff) -#define ELF64_R_SSYM(info) (((info) >> 24) & 0xff) -#define ELF64_R_TYPE3(info) (((info) >> 16) & 0xff) -#define ELF64_R_TYPE2(info) (((info) >> 8) & 0xff) -#define ELF64_R_TYPE(info) (((info) >> 0) & 0xff) -#define ELF64_R_INFO(sym,ssym,type,type2,type3) \ - (((sym) << 32) + ((ssym) << 24) + ((type3) << 16) + ((type2) << 8) + (type)) -#endif -#else -#define ELF64_R_SYM(info) ((info) >> 32) -#define ELF64_R_TYPE(info) ((info) & 0xffffffff) -#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) -#endif - -/* - * Move entries - */ -typedef struct { - Elf32_Lword m_value; /* symbol value */ - Elf32_Word m_info; /* size + index */ - Elf32_Word m_poffset; /* symbol offset */ - Elf32_Half m_repeat; /* repeat count */ - Elf32_Half m_stride; /* stride info */ -} Elf32_Move; - -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) ((info) & 0xff) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF) +#define ELF64_R_INFO(s,t) (((s) << 32) + (__uint32_t)(t)) +/* Program Header */ typedef struct { - Elf64_Lword m_value; /* symbol value */ - Elf64_Xword m_info; /* size + index */ - Elf64_Xword m_poffset; /* symbol offset */ - Elf64_Word m_repeat; /* repeat count */ - Elf64_Word m_stride; /* stride info */ -} Elf64_Move; - -#define ELF64_M_SYM(info) ((info) >> 8) -#define ELF64_M_SIZE(info) ((info) & 0xff) -#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) - -/* - * Hardware/software capabilities entry - */ -typedef struct { - Elf32_Word c_tag; /* entry tag value */ - union { - Elf32_Addr c_ptr; - Elf32_Word c_val; - } c_un; -} Elf32_Cap; + Elf32_Word p_type; /* segment type */ + Elf32_Off p_offset; /* segment offset */ + Elf32_Addr p_vaddr; /* virtual address of segment */ + Elf32_Addr p_paddr; /* physical address - ignored? */ + Elf32_Word p_filesz; /* number of bytes in file for seg. */ + Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory alignment */ +} Elf32_Phdr; typedef struct { - Elf64_Xword c_tag; /* entry tag value */ - union { - Elf64_Addr c_ptr; - Elf64_Xword c_val; - } c_un; -} Elf64_Cap; + Elf64_Half p_type; /* entry type */ + Elf64_Half p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; -/* - * Dynamic Section structure array - */ +/* Segment types - p_type */ +#define PT_NULL 0 /* unused */ +#define PT_LOAD 1 /* loadable segment */ +#define PT_DYNAMIC 2 /* dynamic linking section */ +#define PT_INTERP 3 /* the RTLD */ +#define PT_NOTE 4 /* auxiliary information */ +#define PT_SHLIB 5 /* reserved - purpose undefined */ +#define PT_PHDR 6 /* program header */ +#define PT_NUM 7 /* Number of segment types */ +#define PT_LOOS 0x60000000 /* reserved range for OS */ +#define PT_HIOS 0x6fffffff /* specific segment types */ +#define PT_LOPROC 0x70000000 /* reserved range for processor */ +#define PT_HIPROC 0x7fffffff /* specific segment types */ + +/* Segment flags - p_flags */ +#define PF_X 0x1 /* Executable */ +#define PF_W 0x2 /* Writable */ +#define PF_R 0x4 /* Readable */ +#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ + /* specific segment flags */ + +/* Dynamic structure */ typedef struct { - Elf32_Word d_tag; /* entry tag value */ + Elf32_Sword d_tag; /* controls meaning of d_val */ union { - Elf32_Addr d_ptr; - Elf32_Word d_val; + Elf32_Word d_val; /* Multiple meanings - see d_tag */ + Elf32_Addr d_ptr; /* program virtual address */ } d_un; } Elf32_Dyn; typedef struct { - Elf64_Xword d_tag; /* entry tag value */ + Elf64_Xword d_tag; /* controls meaning of d_val */ union { Elf64_Addr d_ptr; Elf64_Xword d_val; } d_un; } Elf64_Dyn; -/* d_tag */ -#define DT_NULL 0 /* Marks end of dynamic array */ -#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ -#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ -#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocation table */ -#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ -#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ -#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ -#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ -#define DT_INIT 12 /* Address of initialization function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ -#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ -#define DT_SYMBOLIC 16 /* Start symbol search within local object */ -#define DT_REL 17 /* Address of Rel relocation table */ -#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ -#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ -#define DT_PLTREL 20 /* Type of PLT relocation entries */ -#define DT_DEBUG 21 /* Used for debugging; unspecified */ -#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ -#define DT_JMPREL 23 /* Address of relocations associated with PLT */ -#define DT_BIND_NOW 24 /* Process all relocations at load-time */ -#define DT_INIT_ARRAY 25 /* Address of initialization function array */ -#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ -#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ -#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ -#define DT_RUNPATH 29 /* overrides DT_RPATH */ -#define DT_FLAGS 30 /* Encodes ORIGIN, SYMBOLIC, TEXTREL, BIND_NOW, STATIC_TLS */ -#define DT_ENCODING 31 /* ??? */ -#define DT_PREINIT_ARRAY 32 /* Address of pre-init function array */ -#define DT_PREINIT_ARRAYSZ 33 /* Size, in bytes, of DT_PREINIT_ARRAY array */ -#define DT_NUM 34 - -#define DT_LOOS 0x60000000 /* Operating system specific range */ -#define DT_VERSYM 0x6ffffff0 /* Symbol versions */ -#define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ -#define DT_VERDEF 0x6ffffffc /* Versions defined by file */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ -#define DT_VERNEED 0x6ffffffe /* Versions needed by file */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ -#define DT_HIOS 0x6fffffff -#define DT_LOPROC 0x70000000 /* Processor-specific range */ -#define DT_HIPROC 0x7fffffff - -/* Flag values for DT_FLAGS */ -#define DF_ORIGIN 0x00000001 /* uses $ORIGIN */ -#define DF_SYMBOLIC 0x00000002 /* */ -#define DF_TEXTREL 0x00000004 /* */ -#define DF_BIND_NOW 0x00000008 /* */ -#define DF_STATICT_LS 0x00000010 /* */ - -/* Flag values for DT_FLAGS_1 (incomplete) */ -#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ -#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ -#define DF_1_INITFIRST 0x00000020 /* Object's init/fini take priority */ -#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ +/* Dynamic Array Tags - d_tag */ +#define DT_NULL 0 /* marks end of _DYNAMIC array */ +#define DT_NEEDED 1 /* string table offset of needed lib */ +#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ +#define DT_PLTGOT 3 /* address PLT/GOT */ +#define DT_HASH 4 /* address of symbol hash table */ +#define DT_STRTAB 5 /* address of string table */ +#define DT_SYMTAB 6 /* address of symbol table */ +#define DT_RELA 7 /* address of relocation table */ +#define DT_RELASZ 8 /* size of relocation table */ +#define DT_RELAENT 9 /* size of relocation entry */ +#define DT_STRSZ 10 /* size of string table */ +#define DT_SYMENT 11 /* size of symbol table entry */ +#define DT_INIT 12 /* address of initialization func. */ +#define DT_FINI 13 /* address of termination function */ +#define DT_SONAME 14 /* string table offset of shared obj */ +#define DT_RPATH 15 /* string table offset of library + search path */ +#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ +#define DT_REL 17 /* address of rel. tbl. w addends */ +#define DT_RELSZ 18 /* size of DT_REL relocation table */ +#define DT_RELENT 19 /* size of DT_REL relocation entry */ +#define DT_PLTREL 20 /* PLT referenced relocation entry */ +#define DT_DEBUG 21 /* bugger */ +#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */ +#define DT_JMPREL 23 /* add. of PLT's relocation entries */ +#define DT_BIND_NOW 24 /* Bind now regardless of env setting */ +#define DT_NUM 25 /* Number used. */ +#define DT_LOPROC 0x70000000 /* reserved range for processor */ +#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ + +/* Standard ELF hashing function */ +unsigned int elf_hash(const unsigned char *name); /* - * Auxiliary Vectors + * Note Definitions */ typedef struct { - Elf32_Word a_type; /* 32-bit id */ - Elf32_Word a_v; /* 32-bit id */ -} Aux32Info; + Elf32_Word namesz; + Elf32_Word descsz; + Elf32_Word type; +} Elf32_Note; typedef struct { - Elf64_Word a_type; /* 32-bit id */ - Elf64_Xword a_v; /* 64-bit id */ -} Aux64Info; - -/* BEGIN android-changed: these constants should come from <linux/auxvec.h>. */ -#if 0 -/* a_type */ -#define AT_NULL 0 /* Marks end of array */ -#define AT_IGNORE 1 /* No meaning, a_un is undefined */ -#define AT_EXECFD 2 /* Open file descriptor of object file */ -#define AT_PHDR 3 /* &phdr[0] */ -#define AT_PHENT 4 /* sizeof(phdr[0]) */ -#define AT_PHNUM 5 /* # phdr entries */ -#define AT_PAGESZ 6 /* PAGESIZE */ -#define AT_BASE 7 /* Interpreter base addr */ -#define AT_FLAGS 8 /* Processor flags */ -#define AT_ENTRY 9 /* Entry address of executable */ -#define AT_DCACHEBSIZE 10 /* Data cache block size */ -#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ -#define AT_UCACHEBSIZE 12 /* Unified cache block size */ -#define AT_STACKBASE 13 /* Base address of the main thread */ - - /* Vendor specific */ -#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ - -#define AT_EUID 2000 /* euid (solaris compatible numbers) */ -#define AT_RUID 2001 /* ruid (solaris compatible numbers) */ -#define AT_EGID 2002 /* egid (solaris compatible numbers) */ -#define AT_RGID 2003 /* rgid (solaris compatible numbers) */ - - /* Solaris kernel specific */ -#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ -#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ -#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ -#define AT_SUN_LPGSIZE 2007 /* large pagesize */ - - /* Other information */ -#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ -#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ -#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ -#define AT_SUN_CPU 2011 /* CPU name */ - /* ibcs2 emulation band aid */ -#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ -#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ - /* Executable's fully resolved name */ -#define AT_SUN_EXECNAME 2014 -#endif -/* END android-changed */ + Elf64_Half namesz; + Elf64_Half descsz; + Elf64_Half type; +} Elf64_Note; /* - * Note Headers + * XXX - these _KERNEL items aren't part of the ABI! */ -typedef struct { - Elf32_Word n_namesz; - Elf32_Word n_descsz; - Elf32_Word n_type; -} Elf32_Nhdr; - -typedef struct { - Elf64_Word n_namesz; - Elf64_Word n_descsz; - Elf64_Word n_type; -} Elf64_Nhdr; +#if defined(_KERNEL) || defined(_DYN_LOADER) -#define ELF_NOTE_GNU_NAMESZ 4 -#define ELF_NOTE_GNU_NAME "GNU\0" +#define ELF32_NO_ADDR ((u_long) ~0) /* Indicates addr. not yet filled in */ +#define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */ -/* - * GNU-specific note type: ABI tag - * name: GNU\0 - * namesz: 4 - * desc: - * word[0]: OS tag - * word[1]: major version - * word[2]: minor version - * word[3]: teeny version - * descsz: 16 - */ -/* GNU-specific note name and description sizes */ -#define ELF_NOTE_TYPE_ABI_TAG 1 -#define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME -#define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ -#define ELF_NOTE_ABI_DESCSZ 16 -/* GNU-specific OS/version value stuff */ -#define ELF_NOTE_ABI_OS_LINUX 0 -#define ELF_NOTE_ABI_OS_HURD 1 -#define ELF_NOTE_ABI_OS_SOLARIS 2 -#define ELF_NOTE_ABI_OS_KFREEBSD 3 -#define ELF_NOTE_ABI_OS_KNETBSD 4 - -/* - * GNU-specific note type: Hardware capabilities - * name: GNU\0 - * namesz: 4 - * desc: - * word[0]: Number of entries - * word[1]: Bitmask of enabled entries - * Followed by a byte id, and a NUL terminated string per entry - * descsz: variable - */ -#define ELF_NOTE_TYPE_GNU_HWCAP 2 - -/* - * GNU-specific note type: Build ID generated by ld - * name: GNU\0 - * desc: - * word[0..4] SHA1 [default] - * or - * word[0..3] md5 or uuid - * descsz: 16 or 20 - */ -#define ELF_NOTE_TYPE_GNU_BUILD_ID 3 +typedef struct { + Elf32_Sword au_id; /* 32-bit id */ + Elf32_Word au_v; /* 32-bit value */ +} Aux32Info; -/* SuSE-specific note type: ABI - * name: SuSE\0 - * namesz: 5 - * desc: - * half[0] = MMmm - * - * M = product major version - * m = product minor version - * descsz: 2 - */ -#define ELF_NOTE_TYPE_SUSE_TAG 1 -/* SuSE-specific note name and description sizes */ -#define ELF_NOTE_SUSE_NAMESZ 5 -#define ELF_NOTE_SUSE_DESCSZ 2 -/* SuSE-specific note name */ -#define ELF_NOTE_SUSE_NAME "SuSE\0" - -/* SuSE-specific note type: version - * name: SuSE\0\0\0\0 - * namesz: 8 - * desc: - * word[0] = VVTTMMmm - * - * V = version of following data - * T = product type: [box, sles, nld, whatever] - * M = product major version - * m = product minor version - * descsz: 8 - */ -#define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553 /* SuSE in LE */ -/* SuSE-specific note name and description sizes */ -#define ELF_NOTE_SUSE_VERSION_NAMESZ 8 -#define ELF_NOTE_SUSE_VERSION_DESCSZ 8 -/* SuSE-specific note name */ -#define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0" - -/* NetBSD-specific note type: Emulation name. - * name: NetBSD\0\0 - * namesz: 8 - * desc: - * word[0]: MMmmrrpp00 - * - * M = major version - * m = minor version - * r = release ["",A-Z,Z[A-Z] but numeric] - * p = patchlevel - * descsz: 4 - */ -#define ELF_NOTE_TYPE_NETBSD_TAG 1 -/* NetBSD-specific note name and description sizes */ -#define ELF_NOTE_NETBSD_NAMESZ 7 -#define ELF_NOTE_NETBSD_DESCSZ 4 -/* NetBSD-specific note name */ -#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" - -/* NetBSD-specific note type: Checksum. - * There should be 1 NOTE per PT_LOAD section. - * name: ??? - * namesz: ??? - * desc: - * a tuple of <phnum>(16),<chk-type>(16),<chk-value>. - * descsz: ??? - */ -#define ELF_NOTE_TYPE_CHECKSUM_TAG 2 -#define ELF_NOTE_CHECKSUM_CRC32 1 -#define ELF_NOTE_CHECKSUM_MD5 2 -#define ELF_NOTE_CHECKSUM_SHA1 3 -#define ELF_NOTE_CHECKSUM_SHA256 4 +#define ELF64_NO_ADDR ((__uint64_t) ~0)/* Indicates addr. not yet filled in */ +#define ELF64_AUX_ENTRIES 8 /* Size of aux array passed to loader */ -/* - * NetBSD-specific note type: PaX. - * There should be 1 NOTE per executable. - * name: PaX\0 - * namesz: 4 - * desc: - * word[0]: capability bitmask - * descsz: 4 - */ -#define ELF_NOTE_TYPE_PAX_TAG 3 -#define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ -#define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ -#define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ -#define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Servguard */ -#define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ -#define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ -#define ELF_NOTE_PAX_NAMESZ 4 -#define ELF_NOTE_PAX_NAME "PaX\0" -#define ELF_NOTE_PAX_DESCSZ 4 +typedef struct { + Elf64_Shalf au_id; /* 32-bit id */ + Elf64_Xword au_v; /* 64-bit id */ +} Aux64Info; -/* - * NetBSD-specific core file information. - * - * NetBSD ELF core files use notes to provide information about - * the process's state. The note name is "NetBSD-CORE" for - * information that is global to the process, and "NetBSD-CORE@nn", - * where "nn" is the lwpid of the LWP that the information belongs - * to (such as register state). - * - * We use the following note identifiers: - * - * ELF_NOTE_NETBSD_CORE_PROCINFO - * Note is a "netbsd_elfcore_procinfo" structure. - * - * We also use ptrace(2) request numbers (the ones that exist in - * machine-dependent space) to identify register info notes. The - * info in such notes is in the same format that ptrace(2) would - * export that information. - * - * Please try to keep the members of this structure nicely aligned, - * and if you add elements, add them to the end and bump the version. - */ +enum AuxID { + AUX_null = 0, + AUX_ignore = 1, + AUX_execfd = 2, + AUX_phdr = 3, /* &phdr[0] */ + AUX_phent = 4, /* sizeof(phdr[0]) */ + AUX_phnum = 5, /* # phdr entries */ + AUX_pagesz = 6, /* PAGESIZE */ + AUX_base = 7, /* ld.so base addr */ + AUX_flags = 8, /* processor flags */ + AUX_entry = 9, /* a.out entry */ + AUX_sun_uid = 2000, /* euid */ + AUX_sun_ruid = 2001, /* ruid */ + AUX_sun_gid = 2002, /* egid */ + AUX_sun_rgid = 2003 /* rgid */ +}; -#define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" - -#define ELF_NOTE_NETBSD_CORE_PROCINFO 1 - -#define NETBSD_ELFCORE_PROCINFO_VERSION 1 - -struct netbsd_elfcore_procinfo { - /* Version 1 fields start here. */ - uint32_t cpi_version; /* our version */ - uint32_t cpi_cpisize; /* sizeof(this struct) */ - uint32_t cpi_signo; /* killing signal */ - uint32_t cpi_sigcode; /* signal code */ - uint32_t cpi_sigpend[4]; /* pending signals */ - uint32_t cpi_sigmask[4]; /* blocked signals */ - uint32_t cpi_sigignore[4]; /* ignored signals */ - uint32_t cpi_sigcatch[4]; /* caught signals */ - int32_t cpi_pid; /* process ID */ - int32_t cpi_ppid; /* parent process ID */ - int32_t cpi_pgrp; /* process group ID */ - int32_t cpi_sid; /* session ID */ - uint32_t cpi_ruid; /* real user ID */ - uint32_t cpi_euid; /* effective user ID */ - uint32_t cpi_svuid; /* saved user ID */ - uint32_t cpi_rgid; /* real group ID */ - uint32_t cpi_egid; /* effective group ID */ - uint32_t cpi_svgid; /* saved group ID */ - uint32_t cpi_nlwps; /* number of LWPs */ - int8_t cpi_name[32]; /* copy of p->p_comm */ - /* Add version 2 fields below here. */ - int32_t cpi_siglwp; /* LWP target of killing signal */ +struct elf_args { + u_long arg_entry; /* program entry point */ + u_long arg_interp; /* Interpreter load address */ + u_long arg_phaddr; /* program header address */ + u_long arg_phentsize; /* Size of program header */ + u_long arg_phnum; /* Number of program headers */ + u_long arg_os; /* OS tag */ }; -/* - * NetBSD-specific note type: MACHINE_ARCH. - * There should be 1 NOTE per executable. - * name: NetBSD\0 - * namesz: 7 - * desc: string - * descsz: variable - */ -#define ELF_NOTE_TYPE_MARCH_TAG 5 -/* NetBSD-specific note name and description sizes */ -#define ELF_NOTE_MARCH_NAMESZ ELF_NOTE_NETBSD_NAMESZ -/* NetBSD-specific note name */ -#define ELF_NOTE_MARCH_NAME ELF_NOTE_NETBSD_NAME +#endif #if !defined(ELFSIZE) && defined(ARCH_ELFSIZE) #define ELFSIZE ARCH_ELFSIZE @@ -1025,25 +546,25 @@ struct netbsd_elfcore_procinfo { #define Elf_Shdr Elf32_Shdr #define Elf_Sym Elf32_Sym #define Elf_Rel Elf32_Rel -#define Elf_Rela Elf32_Rela +#define Elf_RelA Elf32_Rela #define Elf_Dyn Elf32_Dyn +#define Elf_Half Elf32_Half #define Elf_Word Elf32_Word #define Elf_Sword Elf32_Sword -#define Elf_Half Elf32_Half #define Elf_Addr Elf32_Addr #define Elf_Off Elf32_Off -#define Elf_SOff Elf32_SOff #define Elf_Nhdr Elf32_Nhdr -#define Elf_Verdef Elf32_Verdef -#define Elf_Verdaux Elf32_Verdaux -#define Elf_Verneed Elf32_Verneed -#define Elf_Vernaux Elf32_Vernaux -#define Elf_Versym Elf32_Versym +#define Elf_Note Elf32_Note #define ELF_R_SYM ELF32_R_SYM #define ELF_R_TYPE ELF32_R_TYPE +#define ELF_R_INFO ELF32_R_INFO #define ELFCLASS ELFCLASS32 +#define ELF_ST_BIND ELF32_ST_BIND +#define ELF_ST_TYPE ELF32_ST_TYPE +#define ELF_ST_INFO ELF32_ST_INFO + #define AuxInfo Aux32Info #elif defined(ELFSIZE) && (ELFSIZE == 64) #define Elf_Ehdr Elf64_Ehdr @@ -1051,237 +572,54 @@ struct netbsd_elfcore_procinfo { #define Elf_Shdr Elf64_Shdr #define Elf_Sym Elf64_Sym #define Elf_Rel Elf64_Rel -#define Elf_Rela Elf64_Rela +#define Elf_RelA Elf64_Rela #define Elf_Dyn Elf64_Dyn +#define Elf_Half Elf64_Half #define Elf_Word Elf64_Word #define Elf_Sword Elf64_Sword -#define Elf_Half Elf64_Half #define Elf_Addr Elf64_Addr #define Elf_Off Elf64_Off -#define Elf_SOff Elf64_SOff #define Elf_Nhdr Elf64_Nhdr -#define Elf_Verdef Elf64_Verdef -#define Elf_Verdaux Elf64_Verdaux -#define Elf_Verneed Elf64_Verneed -#define Elf_Vernaux Elf64_Vernaux -#define Elf_Versym Elf64_Versym +#define Elf_Note Elf64_Note #define ELF_R_SYM ELF64_R_SYM #define ELF_R_TYPE ELF64_R_TYPE +#define ELF_R_INFO ELF64_R_INFO #define ELFCLASS ELFCLASS64 -#define AuxInfo Aux64Info -#endif - -#ifndef Elf_Symindx -#define Elf_Symindx uint32_t -#endif - -#define ELF32_ST_BIND(info) ELF_ST_BIND(info) -#define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) -#define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) -#define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) - -#define ELF64_ST_BIND(info) ELF_ST_BIND(info) -#define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) -#define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) -#define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) - -typedef struct { - Elf32_Half si_boundto; /* direct bindings - symbol bound to */ - Elf32_Half si_flags; /* per symbol flags */ -} Elf32_Syminfo; +#define ELF_ST_BIND ELF64_ST_BIND +#define ELF_ST_TYPE ELF64_ST_TYPE +#define ELF_ST_INFO ELF64_ST_INFO -typedef struct { - Elf64_Word si_boundto; /* direct bindings - symbol bound to */ - Elf64_Word si_flags; /* per symbol flags */ -} Elf64_Syminfo; - -#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association - to object containing definition */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ -#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be - lazily-loaded */ -#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to - object containing definition */ -#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference - directly bind to this symbol */ -#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ -#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ - -#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ -#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ -#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ - -#define SYMINFO_NONE 0 /* Syminfo version */ -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - -/* - * These constants are used for Elf32_Verdef struct's version number. - */ -#define VER_DEF_NONE 0 -#define VER_DEF_CURRENT 1 - -/* - * These constants are used for Elf32_Verdef struct's vd_ndx. - */ -#define VER_DEF_IDX(x) VER_NDX(x) - -/* - * These constants are used for Elf32_Verdef struct's vd_flags. - */ -#define VER_FLG_BASE 0x1 -#define VER_FLG_WEAK 0x2 - -/* - * These are used in an Elf32_Versym field. - */ -#define VER_NDX_LOCAL 0 -#define VER_NDX_GLOBAL 1 -#define VER_NDX_GIVEN 2 - -/* - * These constants are used for Elf32_Verneed struct's version number. - */ -#define VER_NEED_NONE 0 -#define VER_NEED_CURRENT 1 - -/* - * These constants are used for Elf32_Vernaux struct's vna_other. - */ -#define VER_NEED_HIDDEN VER_NDX_HIDDEN -#define VER_NEED_IDX(x) VER_NDX(x) - -/* index */ -#define VER_NDX_HIDDEN 0x8000 -#define VER_NDX(x) ((x) & ~VER_NDX_HIDDEN) - -/* - * GNU Extension hidding symbol - */ -#define VERSYM_HIDDEN 0x8000 -#define VERSYM_VERSION 0x7fff - -#define ELF_VER_CHR '@' - -/* - * These are current size independent. - */ - -typedef struct { - Elf32_Half vd_version; /* version number of structure */ - Elf32_Half vd_flags; /* flags (VER_FLG_*) */ - Elf32_Half vd_ndx; /* version index */ - Elf32_Half vd_cnt; /* number of verdaux entries */ - Elf32_Word vd_hash; /* hash of name */ - Elf32_Word vd_aux; /* offset to verdaux entries */ - Elf32_Word vd_next; /* offset to next verdef */ -} Elf32_Verdef; -typedef Elf32_Verdef Elf64_Verdef; - -typedef struct { - Elf32_Word vda_name; /* string table offset of name */ - Elf32_Word vda_next; /* offset to verdaux */ -} Elf32_Verdaux; -typedef Elf32_Verdaux Elf64_Verdaux; - -typedef struct { - Elf32_Half vn_version; /* version number of structure */ - Elf32_Half vn_cnt; /* number of vernaux entries */ - Elf32_Word vn_file; /* string table offset of library name*/ - Elf32_Word vn_aux; /* offset to vernaux entries */ - Elf32_Word vn_next; /* offset to next verneed */ -} Elf32_Verneed; -typedef Elf32_Verneed Elf64_Verneed; - -typedef struct { - Elf32_Word vna_hash; /* Hash of dependency name */ - Elf32_Half vna_flags; /* flags (VER_FLG_*) */ - Elf32_Half vna_other; /* unused */ - Elf32_Word vna_name; /* string table offset to version name*/ - Elf32_Word vna_next; /* offset to next vernaux */ -} Elf32_Vernaux; -typedef Elf32_Vernaux Elf64_Vernaux; - -typedef struct { - Elf32_Half vs_vers; -} Elf32_Versym; -typedef Elf32_Versym Elf64_Versym; - -#ifdef _KERNEL - -#define ELF_AUX_ENTRIES 15 /* Max size of aux array passed to loader */ -#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ -#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */ -#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ -#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */ - -#if defined(ELFSIZE) && (ELFSIZE == 64) -#define ELF_NO_ADDR ELF64_NO_ADDR -#define ELF_LINK_ADDR ELF64_LINK_ADDR -#elif defined(ELFSIZE) && (ELFSIZE == 32) -#define ELF_NO_ADDR ELF32_NO_ADDR -#define ELF_LINK_ADDR ELF32_LINK_ADDR -#endif - -#ifndef ELF32_EHDR_FLAGS_OK -#define ELF32_EHDR_FLAGS_OK(eh) 1 -#endif - -#ifndef ELF64_EHDR_FLAGS_OK -#define ELF64_EHDR_FLAGS_OK(eh) 1 -#endif - -#if defined(ELFSIZE) && (ELFSIZE == 64) -#define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) -#else -#define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) -#endif - -#if defined(ELFSIZE) -struct elf_args { - Elf_Addr arg_entry; /* program entry point */ - Elf_Addr arg_interp; /* Interpreter load address */ - Elf_Addr arg_phaddr; /* program header address */ - Elf_Addr arg_phentsize; /* Size of program header */ - Elf_Addr arg_phnum; /* Number of program headers */ -}; +#define AuxInfo Aux64Info #endif -#ifdef _KERNEL_OPT -#include "opt_execfmt.h" +#ifndef _KERNEL +extern Elf_Dyn _DYNAMIC[]; #endif -struct ps_strings; - -#ifdef EXEC_ELF32 -int exec_elf32_makecmds(struct lwp *, struct exec_package *); -int elf32_copyargs(struct lwp *, struct exec_package *, - struct ps_strings *, char **, void *); - -int coredump_elf32(struct lwp *, void *); -int coredump_writenote_elf32(struct proc *, void *, Elf32_Nhdr *, - const char *, void *); - -int elf32_check_header(Elf32_Ehdr *, int); +#ifdef _KERNEL +#ifdef _KERN_DO_ELF64 +int exec_elf64_makecmds(struct proc *, struct exec_package *); +void *elf64_copyargs(struct exec_package *, struct ps_strings *, + void *, void *); +int exec_elf64_fixup(struct proc *, struct exec_package *); +char *elf64_check_brand(Elf64_Ehdr *); +int elf64_os_pt_note(struct proc *, struct exec_package *, Elf64_Ehdr *, + char *, size_t, size_t); #endif - -#ifdef EXEC_ELF64 -int exec_elf64_makecmds(struct lwp *, struct exec_package *); -int elf64_copyargs(struct lwp *, struct exec_package *, - struct ps_strings *, char **, void *); - -int coredump_elf64(struct lwp *, void *); -int coredump_writenote_elf64(struct proc *, void *, Elf64_Nhdr *, - const char *, void *); - -int elf64_check_header(Elf64_Ehdr *, int); +#ifdef _KERN_DO_ELF +int exec_elf32_makecmds(struct proc *, struct exec_package *); +void *elf32_copyargs(struct exec_package *, struct ps_strings *, + void *, void *); +int exec_elf32_fixup(struct proc *, struct exec_package *); +char *elf32_check_brand(Elf32_Ehdr *); +int elf32_os_pt_note(struct proc *, struct exec_package *, Elf32_Ehdr *, + char *, size_t, size_t); #endif #endif /* _KERNEL */ -#endif /* !_SYS_EXEC_ELF_H_ */ +#define ELF_TARG_VER 1 /* The ver for which this code is intended */ + +#endif /* _SYS_EXEC_ELF_H_ */ diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/klog.h b/9/platforms/android-19/arch-arm64/usr/include/sys/klog.h index 02851d2..acfaa20 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/klog.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/klog.h @@ -25,6 +25,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #ifndef _SYS_KLOG_H_ #define _SYS_KLOG_H_ @@ -45,13 +46,6 @@ __BEGIN_DECLS #define KLOG_SIZE_UNREAD 9 #define KLOG_SIZE_BUFFER 10 -/* These are deprecated names that were used in earlier bionic releases. Do not use. */ -#define KLOG_DISABLE 6 -#define KLOG_ENABLE 7 -#define KLOG_SETLEVEL 8 -#define KLOG_UNREADSIZE 9 -#define KLOG_WRITE 10 - extern int klogctl(int, char *, int); __END_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/mman.h b/9/platforms/android-19/arch-arm64/usr/include/sys/mman.h index 7c5f8d7..5a8c985 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/mman.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/mman.h @@ -31,7 +31,6 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <asm/mman.h> -#include <asm/page.h> __BEGIN_DECLS @@ -44,23 +43,23 @@ __BEGIN_DECLS #define MREMAP_MAYMOVE 1 #define MREMAP_FIXED 2 -extern void* mmap(void *, size_t, int, int, int, off_t); -extern void* mmap64(void *, size_t, int, int, int, off64_t); -extern int munmap(void *, size_t); -extern int msync(const void *, size_t, int); -extern int mprotect(const void *, size_t, int); -extern void* mremap(void *, size_t, size_t, unsigned long); +extern void* mmap(void*, size_t, int, int, int, off_t); +extern void* mmap64(void*, size_t, int, int, int, off64_t); +extern int munmap(void*, size_t); +extern int msync(const void*, size_t, int); +extern int mprotect(const void*, size_t, int); +extern void* mremap(void*, size_t, size_t, unsigned long); -extern int mlockall(int); -extern int munlockall(void); -extern int mlock(const void *, size_t); -extern int munlock(const void *, size_t); -extern int madvise(const void *, size_t, int); +extern int mlockall(int); +extern int munlockall(void); +extern int mlock(const void*, size_t); +extern int munlock(const void*, size_t); +extern int madvise(const void*, size_t, int); -extern int mlock(const void *addr, size_t len); -extern int munlock(const void *addr, size_t len); +extern int mlock(const void*, size_t); +extern int munlock(const void*, size_t); -extern int mincore(void* start, size_t length, unsigned char* vec); +extern int mincore(void*, size_t, unsigned char*); __END_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/socket.h b/9/platforms/android-19/arch-arm64/usr/include/sys/socket.h index 32d98ea..62a5300 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/socket.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/socket.h @@ -43,8 +43,9 @@ __BEGIN_DECLS #define sockaddr_storage __kernel_sockaddr_storage -typedef __sa_family_t sa_family_t; -typedef int socklen_t; +typedef unsigned short sa_family_t; + +struct timespec; #ifdef __mips__ #define SOCK_DGRAM 1 @@ -76,40 +77,45 @@ enum { }; struct sockaddr { - sa_family_t sa_family; - char sa_data[14]; + sa_family_t sa_family; + char sa_data[14]; }; struct linger { - int l_onoff; - int l_linger; + int l_onoff; + int l_linger; }; struct msghdr { - void * msg_name; - int msg_namelen; - struct iovec * msg_iov; - __kernel_size_t msg_iovlen; - void * msg_control; - __kernel_size_t msg_controllen; - unsigned msg_flags; + void* msg_name; + socklen_t msg_namelen; + struct iovec* msg_iov; + size_t msg_iovlen; + void* msg_control; + size_t msg_controllen; + int msg_flags; +}; + +struct mmsghdr { + struct msghdr msg_hdr; + unsigned int msg_len; }; struct cmsghdr { - __kernel_size_t cmsg_len; - int cmsg_level; - int cmsg_type; + size_t cmsg_len; + int cmsg_level; + int cmsg_type; }; #define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg)) #define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg)) #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) -#define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))) +#define CMSG_DATA(cmsg) ((void*)((char*)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))) #define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len)) #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) -#define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? (struct cmsghdr *)(ctl) : (struct cmsghdr *)NULL) +#define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? (struct cmsghdr*)(ctl) : (struct cmsghdr*)NULL) #define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) -#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && (cmsg)->cmsg_len <= (unsigned long) ((mhdr)->msg_controllen - ((char *)(cmsg) - (char *)(mhdr)->msg_control))) +#define CMSG_OK(mhdr, cmsg) ((cmsg)->cmsg_len >= sizeof(struct cmsghdr) && (cmsg)->cmsg_len <= (unsigned long) ((mhdr)->msg_controllen - ((char*)(cmsg) - (char*)(mhdr)->msg_control))) #ifdef __GNUC__ #define __KINLINE static __inline__ @@ -119,16 +125,17 @@ struct cmsghdr { #define __KINLINE static #endif -__KINLINE struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size, struct cmsghdr *__cmsg) { - struct cmsghdr * __ptr; - __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); - if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) - return (struct cmsghdr *)0; - return __ptr; +__KINLINE struct cmsghdr* __cmsg_nxthdr(void* __ctl, size_t __size, struct cmsghdr* __cmsg) { + struct cmsghdr* __ptr; + __ptr = (struct cmsghdr*)(((unsigned char*) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); + if ((unsigned long)((char*)(__ptr+1) - (char*) __ctl) > __size) { + return NULL; + } + return __ptr; } -__KINLINE struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg) { - return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); +__KINLINE struct cmsghdr* cmsg_nxthdr (struct msghdr* __msg, struct cmsghdr* __cmsg) { + return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); } #define SCM_RIGHTS 0x01 @@ -136,9 +143,9 @@ __KINLINE struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__ #define SCM_SECURITY 0x03 struct ucred { - __u32 pid; - __u32 uid; - __u32 gid; + pid_t pid; + uid_t uid; + gid_t gid; }; #define AF_UNSPEC 0 @@ -242,6 +249,9 @@ struct ucred { #define MSG_ERRQUEUE 0x2000 #define MSG_NOSIGNAL 0x4000 #define MSG_MORE 0x8000 +#define MSG_WAITFORONE 0x10000 +#define MSG_FASTOPEN 0x20000000 +#define MSG_CMSG_CLOEXEC 0x40000000 #define MSG_EOF MSG_FIN #define MSG_CMSG_COMPAT 0 @@ -277,43 +287,45 @@ struct ucred { # define __socketcall extern #endif -__socketcall int socket(int, int, int); -__socketcall int bind(int, const struct sockaddr *, int); -__socketcall int connect(int, const struct sockaddr *, socklen_t); +__socketcall int accept(int, struct sockaddr*, socklen_t*); +__socketcall int bind(int, const struct sockaddr*, int); +__socketcall int connect(int, const struct sockaddr*, socklen_t); +__socketcall int getpeername(int, struct sockaddr*, socklen_t*); +__socketcall int getsockname(int, struct sockaddr*, socklen_t*); +__socketcall int getsockopt(int, int, int, void*, socklen_t*); __socketcall int listen(int, int); -__socketcall int accept(int, struct sockaddr *, socklen_t *); -__socketcall int getsockname(int, struct sockaddr *, socklen_t *); -__socketcall int getpeername(int, struct sockaddr *, socklen_t *); -__socketcall int socketpair(int, int, int, int *); +__socketcall int recvmmsg(int, struct mmsghdr*, unsigned int, int, const struct timespec*); +__socketcall int recvmsg(int, struct msghdr*, int); +__socketcall int sendmmsg(int, const struct mmsghdr*, unsigned int, int); +__socketcall int sendmsg(int, const struct msghdr*, int); +__socketcall int setsockopt(int, int, int, const void*, socklen_t); __socketcall int shutdown(int, int); -__socketcall int setsockopt(int, int, int, const void *, socklen_t); -__socketcall int getsockopt(int, int, int, void *, socklen_t *); -__socketcall int sendmsg(int, const struct msghdr *, unsigned int); -__socketcall int recvmsg(int, struct msghdr *, unsigned int); +__socketcall int socket(int, int, int); +__socketcall int socketpair(int, int, int, int*); -extern ssize_t send(int, const void *, size_t, unsigned int); -extern ssize_t recv(int, void *, size_t, unsigned int); +extern ssize_t send(int, const void*, size_t, int); +extern ssize_t recv(int, void*, size_t, int); -__socketcall ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t); -__socketcall ssize_t recvfrom(int, void *, size_t, unsigned int, const struct sockaddr *, socklen_t *); +__socketcall ssize_t sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t); +__socketcall ssize_t recvfrom(int, void*, size_t, int, const struct sockaddr*, socklen_t*); #if defined(__BIONIC_FORTIFY) __errordecl(__recvfrom_error, "recvfrom called with size bigger than buffer"); -extern ssize_t __recvfrom_chk(int, void*, size_t, size_t, unsigned int, const struct sockaddr*, socklen_t *); -extern ssize_t __recvfrom_real(int, void *, size_t, unsigned int, const struct sockaddr*, socklen_t*) +extern ssize_t __recvfrom_chk(int, void*, size_t, size_t, int, const struct sockaddr*, socklen_t*); +extern ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen_t*) __asm__(__USER_LABEL_PREFIX__ "recvfrom"); __BIONIC_FORTIFY_INLINE -ssize_t recvfrom(int fd, void* buf, size_t len, unsigned int flags, const struct sockaddr* src_addr, socklen_t* addrlen) { +ssize_t recvfrom(int fd, void* buf, size_t len, int flags, const struct sockaddr* src_addr, socklen_t* addr_len) { size_t bos = __bos0(buf); #if !defined(__clang__) if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) { - return __recvfrom_real(fd, buf, len, flags, src_addr, addrlen); + return __recvfrom_real(fd, buf, len, flags, src_addr, addr_len); } if (__builtin_constant_p(len) && (len <= bos)) { - return __recvfrom_real(fd, buf, len, flags, src_addr, addrlen); + return __recvfrom_real(fd, buf, len, flags, src_addr, addr_len); } if (__builtin_constant_p(len) && (len > bos)) { @@ -321,12 +333,12 @@ ssize_t recvfrom(int fd, void* buf, size_t len, unsigned int flags, const struct } #endif - return __recvfrom_chk(fd, buf, len, bos, flags, src_addr, addrlen); + return __recvfrom_chk(fd, buf, len, bos, flags, src_addr, addr_len); } __BIONIC_FORTIFY_INLINE -ssize_t recv(int socket, void *buf, size_t buflen, unsigned int flags) { - return recvfrom(socket, buf, buflen, flags, NULL, 0); +ssize_t recv(int socket, void* buf, size_t len, int flags) { + return recvfrom(socket, buf, len, flags, NULL, 0); } #endif /* __BIONIC_FORTIFY */ diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/stat.h b/9/platforms/android-19/arch-arm64/usr/include/sys/stat.h index 37b8dc2..e62e76d 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/stat.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/stat.h @@ -38,101 +38,101 @@ __BEGIN_DECLS #if defined(__aarch64__) -struct stat { - unsigned long st_dev; - unsigned long st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned long st_rdev; - unsigned long __pad1; - long st_size; - int st_blksize; - int __pad2; - long st_blocks; - long st_atime; - unsigned long st_atime_nsec; - long st_mtime; - unsigned long st_mtime_nsec; - long st_ctime; - unsigned long st_ctime_nsec; - unsigned int __unused4; - unsigned int __unused5; -}; +#define __STAT64_BODY \ + unsigned long st_dev; \ + unsigned long st_ino; \ + unsigned int st_mode; \ + unsigned int st_nlink; \ + uid_t st_uid; \ + gid_t st_gid; \ + unsigned long st_rdev; \ + unsigned long __pad1; \ + long st_size; \ + int st_blksize; \ + int __pad2; \ + long st_blocks; \ + long st_atime; \ + unsigned long st_atime_nsec; \ + long st_mtime; \ + unsigned long st_mtime_nsec; \ + long st_ctime; \ + unsigned long st_ctime_nsec; \ + unsigned int __unused4; \ + unsigned int __unused5; \ + #elif defined(__mips__) -struct stat { - unsigned int st_dev; - unsigned int __pad0[3]; - unsigned long long st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned int st_rdev; - unsigned int __pad1[3]; - long long st_size; - unsigned int st_atime; - unsigned int st_atime_nsec; - unsigned int st_mtime; - unsigned int st_mtime_nsec; - unsigned int st_ctime; - unsigned int st_ctime_nsec; - unsigned int st_blksize; - unsigned int __pad2; - unsigned long long st_blocks; -}; +#define __STAT64_BODY \ + unsigned int st_dev; \ + unsigned int __pad0[3]; \ + unsigned long long st_ino; \ + unsigned int st_mode; \ + unsigned int st_nlink; \ + uid_t st_uid; \ + gid_t st_gid; \ + unsigned int st_rdev; \ + unsigned int __pad1[3]; \ + long long st_size; \ + unsigned int st_atime; \ + unsigned int st_atime_nsec; \ + unsigned int st_mtime; \ + unsigned int st_mtime_nsec; \ + unsigned int st_ctime; \ + unsigned int st_ctime_nsec; \ + unsigned int st_blksize; \ + unsigned int __pad2; \ + unsigned long long st_blocks; \ + #elif defined(__x86_64__) -struct stat { - unsigned long st_dev; - unsigned long st_ino; - unsigned long st_nlink; - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int __pad0; - unsigned long st_rdev; - long st_size; - long st_blksize; - long st_blocks; - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned long st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - long __pad3[3]; -}; +#define __STAT64_BODY \ + unsigned long st_dev; \ + unsigned long st_ino; \ + unsigned long st_nlink; \ + unsigned int st_mode; \ + uid_t st_uid; \ + gid_t st_gid; \ + unsigned int __pad0; \ + unsigned long st_rdev; \ + long st_size; \ + long st_blksize; \ + long st_blocks; \ + unsigned long st_atime; \ + unsigned long st_atime_nsec; \ + unsigned long st_mtime; \ + unsigned long st_mtime_nsec; \ + unsigned long st_ctime; \ + unsigned long st_ctime_nsec; \ + long __pad3[3]; \ + #else -struct stat { - unsigned long long st_dev; - unsigned char __pad0[4]; - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned long st_uid; - unsigned long st_gid; - unsigned long long st_rdev; - unsigned char __pad3[4]; - long long st_size; - unsigned long st_blksize; - unsigned long long st_blocks; - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned long st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - unsigned long long st_ino; -}; +#define __STAT64_BODY \ + unsigned long long st_dev; \ + unsigned char __pad0[4]; \ + unsigned long __st_ino; \ + unsigned int st_mode; \ + unsigned int st_nlink; \ + uid_t st_uid; \ + gid_t st_gid; \ + unsigned long long st_rdev; \ + unsigned char __pad3[4]; \ + long long st_size; \ + unsigned long st_blksize; \ + unsigned long long st_blocks; \ + unsigned long st_atime; \ + unsigned long st_atime_nsec; \ + unsigned long st_mtime; \ + unsigned long st_mtime_nsec; \ + unsigned long st_ctime; \ + unsigned long st_ctime_nsec; \ + unsigned long long st_ino; \ + #endif -/* For compatibility with GLibc, we provide macro aliases - * for the non-Posix nano-seconds accessors. - */ -#define st_atimensec st_atime_nsec -#define st_mtimensec st_mtime_nsec -#define st_ctimensec st_ctime_nsec +struct stat { __STAT64_BODY }; +struct stat64 { __STAT64_BODY }; + +#define st_atimensec st_atime_nsec +#define st_mtimensec st_mtime_nsec +#define st_ctimensec st_ctime_nsec #ifdef __USE_BSD /* Permission macros provided by glibc for compatibility with BSDs. */ @@ -141,21 +141,26 @@ struct stat { #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */ #endif -extern int chmod(const char *, mode_t); -extern int fchmod(int, mode_t); -extern int mkdir(const char *, mode_t); +extern int chmod(const char*, mode_t); +extern int fchmod(int, mode_t); +extern int mkdir(const char*, mode_t); -extern int stat(const char *, struct stat *); -extern int fstat(int, struct stat *); -extern int lstat(const char *, struct stat *); -extern int mknod(const char *, mode_t, dev_t); +extern int fstat(int, struct stat*); +extern int fstat64(int, struct stat64*); +extern int fstatat(int, const char*, struct stat*, int); +extern int fstatat64(int, const char*, struct stat64*, int); +extern int lstat(const char*, struct stat*); +extern int lstat64(const char*, struct stat64*); +extern int stat(const char*, struct stat*); +extern int stat64(const char*, struct stat64*); + +extern int mknod(const char*, mode_t, dev_t); extern mode_t umask(mode_t); #if defined(__BIONIC_FORTIFY) extern mode_t __umask_chk(mode_t); -extern mode_t __umask_real(mode_t) - __asm__(__USER_LABEL_PREFIX__ "umask"); +extern mode_t __umask_real(mode_t) __asm__(__USER_LABEL_PREFIX__ "umask"); __errordecl(__umask_invalid_mode, "umask called with invalid mode"); __BIONIC_FORTIFY_INLINE @@ -172,20 +177,14 @@ mode_t umask(mode_t mode) { } #endif /* defined(__BIONIC_FORTIFY) */ - -#define stat64 stat -#define fstat64 fstat -#define lstat64 lstat - extern int mkfifo(const char*, mode_t); extern int fchmodat(int, const char*, mode_t, int); -extern int fstatat(int, const char*, struct stat*, int); extern int mkdirat(int, const char*, mode_t); extern int mknodat(int, const char*, mode_t, dev_t); -# define UTIME_NOW ((1l << 30) - 1l) -# define UTIME_OMIT ((1l << 30) - 2l) +#define UTIME_NOW ((1L << 30) - 1L) +#define UTIME_OMIT ((1L << 30) - 2L) extern int utimensat(int fd, const char *path, const struct timespec times[2], int flags); extern int futimens(int fd, const struct timespec times[2]); diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/statvfs.h b/9/platforms/android-19/arch-arm64/usr/include/sys/statvfs.h index e910c03..3d8179e 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/statvfs.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/statvfs.h @@ -23,19 +23,21 @@ __BEGIN_DECLS -struct statvfs { - unsigned long f_bsize; - unsigned long f_frsize; - fsblkcnt_t f_blocks; - fsblkcnt_t f_bfree; - fsblkcnt_t f_bavail; - fsfilcnt_t f_files; - fsfilcnt_t f_ffree; - fsfilcnt_t f_favail; - unsigned long f_fsid; - unsigned long f_flag; - unsigned long f_namemax; -}; +#define __STATVFS64_BODY \ + unsigned long f_bsize; \ + unsigned long f_frsize; \ + fsblkcnt_t f_blocks; \ + fsblkcnt_t f_bfree; \ + fsblkcnt_t f_bavail; \ + fsfilcnt_t f_files; \ + fsfilcnt_t f_ffree; \ + fsfilcnt_t f_favail; \ + unsigned long f_fsid; \ + unsigned long f_flag; \ + unsigned long f_namemax; \ + +struct statvfs { __STATVFS64_BODY }; +struct statvfs64 { __STATVFS64_BODY }; #define ST_RDONLY 0x0001 #define ST_NOSUID 0x0002 @@ -48,7 +50,9 @@ struct statvfs { #define ST_RELATIME 0x1000 extern int statvfs(const char* __restrict, struct statvfs* __restrict) __nonnull((1, 2)); +extern int statvfs64(const char* __restrict, struct statvfs64* __restrict) __nonnull((1, 2)); extern int fstatvfs(int, struct statvfs*) __nonnull((2)); +extern int fstatvfs64(int, struct statvfs64*) __nonnull((2)); __END_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/times.h b/9/platforms/android-19/arch-arm64/usr/include/sys/times.h index 1b9b8b2..6ce5b55 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/times.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/times.h @@ -25,6 +25,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #ifndef _SYS_TIMES_H_ #define _SYS_TIMES_H_ @@ -34,7 +35,7 @@ __BEGIN_DECLS -extern clock_t times(struct tms *); +extern clock_t times(struct tms*); __END_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/types.h b/9/platforms/android-19/arch-arm64/usr/include/sys/types.h index f8ae813..dc847d2 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/types.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/types.h @@ -35,28 +35,48 @@ #include <linux/types.h> #include <linux/posix_types.h> -/* __kernel_gid_t and __kernel_uid_t are 16 bit for legacy reasons. - * Android uses __kernel_uid32_t and __kernel_gid32_t instead. - */ -typedef __kernel_gid32_t gid_t; -typedef __kernel_uid32_t uid_t; +/* gids, uids, and pids are all 32-bit. */ +typedef __kernel_gid32_t __gid_t; +typedef __gid_t gid_t; +typedef __kernel_uid32_t __uid_t; +typedef __uid_t uid_t; +typedef __kernel_pid_t __pid_t; +typedef __pid_t pid_t; +typedef uint32_t __id_t; +typedef __id_t id_t; typedef unsigned long blkcnt_t; typedef unsigned long blksize_t; typedef __kernel_caddr_t caddr_t; typedef __kernel_clock_t clock_t; -typedef __kernel_clockid_t clockid_t; + +typedef __kernel_clockid_t __clockid_t; +typedef __clockid_t clockid_t; + typedef __kernel_daddr_t daddr_t; typedef unsigned long fsblkcnt_t; typedef unsigned long fsfilcnt_t; -typedef __kernel_ino_t ino_t; -typedef __kernel_key_t key_t; -typedef __kernel_mode_t mode_t; + +typedef __kernel_mode_t __mode_t; +typedef __mode_t mode_t; + +typedef __kernel_key_t __key_t; +typedef __key_t key_t; + +typedef uint32_t __ino_t; +typedef __ino_t ino_t; + +typedef uint32_t __nlink_t; typedef __nlink_t nlink_t; -typedef __kernel_pid_t pid_t; -typedef __kernel_suseconds_t suseconds_t; -typedef __kernel_timer_t timer_t; -typedef unsigned int useconds_t; + +typedef void* __timer_t; +typedef __timer_t timer_t; + +typedef int32_t __suseconds_t; +typedef __suseconds_t suseconds_t; + +typedef uint32_t __useconds_t; +typedef __useconds_t useconds_t; #if !defined(__LP64__) /* This historical accident means that we had a 32-bit dev_t on 32-bit architectures. */ @@ -66,7 +86,8 @@ typedef uint64_t dev_t; #endif /* This historical accident means that we had a 32-bit time_t on 32-bit architectures. */ -typedef __kernel_time_t time_t; +typedef __kernel_time_t __time_t; +typedef __time_t time_t; /* This historical accident means that we had a 32-bit off_t on 32-bit architectures. */ #ifndef _OFF_T_DEFINED_ @@ -76,9 +97,6 @@ typedef __kernel_off_t off_t; typedef __kernel_loff_t loff_t; typedef loff_t off64_t; -/* This one really is meant to be just 32 bits! */ -typedef uint32_t id_t; - /* while POSIX wants these in <sys/types.h>, we * declare then in <pthread.h> instead */ #if 0 @@ -93,6 +111,17 @@ typedef .... pthread_rwlock_attr_t; typedef .... pthread_t; #endif +#if !defined(__LP64__) +/* This historical accident means that we had a signed socklen_t on 32-bit architectures. */ +typedef int32_t __socklen_t; +#else +/* LP64 still has a 32-bit socklen_t. */ +typedef uint32_t __socklen_t; +#endif +typedef __socklen_t socklen_t; + +typedef __builtin_va_list __va_list; + #ifndef _SSIZE_T_DEFINED_ #define _SSIZE_T_DEFINED_ /* Traditionally, bionic's ssize_t was "long int". This caused GCC to emit warnings when you diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/un.h b/9/platforms/android-19/arch-arm64/usr/include/sys/un.h index f89ead3..65ffbdc 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/un.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/un.h @@ -28,8 +28,7 @@ #ifndef _SYS_UN_H_ #define _SYS_UN_H_ -#include <sys/_types.h> -typedef __sa_family_t sa_family_t; +typedef unsigned short sa_family_t; #include <linux/un.h> diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/user.h b/9/platforms/android-19/arch-arm64/usr/include/sys/user.h index 90cce80..e16b1a5 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/user.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/user.h @@ -30,6 +30,7 @@ #define _SYS_USER_H_ #include <sys/cdefs.h> +#include <limits.h> /* For PAGE_SIZE. */ __BEGIN_DECLS diff --git a/9/platforms/android-19/arch-arm64/usr/include/sys/vfs.h b/9/platforms/android-19/arch-arm64/usr/include/sys/vfs.h index fd2655c..cd6044d 100644 --- a/9/platforms/android-19/arch-arm64/usr/include/sys/vfs.h +++ b/9/platforms/android-19/arch-arm64/usr/include/sys/vfs.h @@ -38,76 +38,74 @@ __BEGIN_DECLS typedef struct { int __val[2]; } __fsid_t; typedef __fsid_t fsid_t; -#if defined(__LP64__) -#if defined(__mips__) -/* 64-bit MIPS */ -struct statfs { - uint64_t f_type; - uint64_t f_bsize; - uint64_t f_frsize; /* Fragment size - unsupported */ - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_bavail; - fsid_t f_fsid; - uint64_t f_namelen; - uint64_t f_flags; - uint64_t f_spare[5]; -}; -#else -struct statfs { - uint64_t f_type; - uint64_t f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - fsid_t f_fsid; - uint64_t f_namelen; - uint64_t f_frsize; - uint64_t f_flags; - uint64_t f_spare[4]; -}; -#endif +#if defined(__aarch64__) || defined(__x86_64__) +#define __STATFS64_BODY \ + uint64_t f_type; \ + uint64_t f_bsize; \ + uint64_t f_blocks; \ + uint64_t f_bfree; \ + uint64_t f_bavail; \ + uint64_t f_files; \ + uint64_t f_ffree; \ + fsid_t f_fsid; \ + uint64_t f_namelen; \ + uint64_t f_frsize; \ + uint64_t f_flags; \ + uint64_t f_spare[4]; \ + +#elif defined(__mips__) && defined(__LP64__) +/* 64-bit MIPS. */ +#define __STATFS64_BODY \ + uint64_t f_type; \ + uint64_t f_bsize; \ + uint64_t f_frsize; /* Fragment size - unsupported. */ \ + uint64_t f_blocks; \ + uint64_t f_bfree; \ + uint64_t f_files; \ + uint64_t f_ffree; \ + uint64_t f_bavail; \ + fsid_t f_fsid; \ + uint64_t f_namelen; \ + uint64_t f_flags; \ + uint64_t f_spare[5]; \ + #elif defined(__mips__) /* 32-bit MIPS (corresponds to the kernel's statfs64 type). */ -struct statfs { - uint32_t f_type; - uint32_t f_bsize; - uint32_t f_frsize; - uint32_t __pad; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_files; - uint64_t f_ffree; - uint64_t f_bavail; - fsid_t f_fsid; - uint32_t f_namelen; - uint32_t f_flags; - uint32_t f_spare[5]; -}; +#define __STATFS64_BODY \ + uint32_t f_type; \ + uint32_t f_bsize; \ + uint32_t f_frsize; \ + uint32_t __pad; \ + uint64_t f_blocks; \ + uint64_t f_bfree; \ + uint64_t f_files; \ + uint64_t f_ffree; \ + uint64_t f_bavail; \ + fsid_t f_fsid; \ + uint32_t f_namelen; \ + uint32_t f_flags; \ + uint32_t f_spare[5]; \ + #else /* 32-bit ARM or x86 (corresponds to the kernel's statfs64 type). */ -struct statfs { - uint32_t f_type; - uint32_t f_bsize; - uint64_t f_blocks; - uint64_t f_bfree; - uint64_t f_bavail; - uint64_t f_files; - uint64_t f_ffree; - fsid_t f_fsid; - uint32_t f_namelen; - uint32_t f_frsize; - uint32_t f_flags; - uint32_t f_spare[4]; -}; +#define __STATFS64_BODY \ + uint32_t f_type; \ + uint32_t f_bsize; \ + uint64_t f_blocks; \ + uint64_t f_bfree; \ + uint64_t f_bavail; \ + uint64_t f_files; \ + uint64_t f_ffree; \ + fsid_t f_fsid; \ + uint32_t f_namelen; \ + uint32_t f_frsize; \ + uint32_t f_flags; \ + uint32_t f_spare[4]; \ + #endif -/* Source compatibility with glibc. */ -#define statfs64 statfs +struct statfs { __STATFS64_BODY }; +struct statfs64 { __STATFS64_BODY }; /* Declare that we have the f_namelen, f_frsize, and f_flags fields. */ #define _STATFS_F_NAMELEN @@ -160,7 +158,9 @@ struct statfs { #define _XIAFS_SUPER_MAGIC 0x012FD16D extern int statfs(const char*, struct statfs*) __nonnull((1, 2)); +extern int statfs64(const char*, struct statfs64*) __nonnull((1, 2)); extern int fstatfs(int, struct statfs*) __nonnull((2)); +extern int fstatfs64(int, struct statfs64*) __nonnull((2)); __END_DECLS |