ELF64 support (#220)

* include: Introduce elf64.h and elf.h

    Added elf64.h for 64bit ELF support and moved common definitions
    from elf32.h to elf.h. Also introduced Elf_xxx to be used in
    common libraries such as binfmt.

  * binfmt, include, modlib, module: Add support for ELF64

    Elf_xxx must be used instead of Elf32_xxx to support ELF64.
    To use ELF64, CONFIG_ELF_64BIT must be enabled.

  * binfmt, modlib: Add support for relocate address

  * arch: risc-v: Add include/elf.h

  * libs: machine: Add risc-v related files.

    NOTE: Currently only supports ELF64

  * boards: maix-bit: Add elf and posix_spawn configurations

  * boards: maix-bit: Add support for module configuration
This commit is contained in:
Masayuki Ishikawa
2020-02-07 17:10:23 -06:00
committed by Gregory Nutt
parent e21c30cf9d
commit 81f1133174
40 changed files with 1847 additions and 300 deletions
+86
View File
@@ -0,0 +1,86 @@
/****************************************************************************
* arch/risc-v/include/elf.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_RISCV_INCLUDE_ELF_H
#define __ARCH_RISCV_INCLUDE_ELF_H
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md */
#define R_RISCV_NONE 0
#define R_RISCV_32 1
#define R_RISCV_64 2
#define R_RISCV_RELATIVE 3
#define R_RISCV_COPY 4
#define R_RISCV_JUMP_SLOT 5
#define R_RISCV_TLS_DTPMOD32 6
#define R_RISCV_TLS_DTPMOD64 7
#define R_RISCV_TLS_DTPREL32 8
#define R_RISCV_TLS_DTPREL64 9
#define R_RISCV_TLS_TPREL32 10
#define R_RISCV_TLS_TPREL64 11
#define R_RISCV_BRANCH 16
#define R_RISCV_JAL 17
#define R_RISCV_CALL 18
#define R_RISCV_CALL_PLT 19
#define R_RISCV_GOT_HI20 20
#define R_RISCV_TLS_GOT_HI20 21
#define R_RISCV_TLS_GD_HI20 22
#define R_RISCV_PCREL_HI20 23
#define R_RISCV_PCREL_LO12_I 24
#define R_RISCV_PCREL_LO12_S 25
#define R_RISCV_HI20 26
#define R_RISCV_LO12_I 27
#define R_RISCV_LO12_S 28
#define R_RISCV_TPREL_HI20 29
#define R_RISCV_TPREL_LO12_I 30
#define R_RISCV_TPREL_LO12_S 31
#define R_RISCV_TPREL_ADD 32
#define R_RISCV_ADD8 33
#define R_RISCV_ADD16 34
#define R_RISCV_ADD32 35
#define R_RISCV_ADD64 36
#define R_RISCV_SUB8 37
#define R_RISCV_SUB16 38
#define R_RISCV_SUB32 39
#define R_RISCV_SUB64 40
#define R_RISCV_GNU_VTINHERIT 41
#define R_RISCV_GNU_VTENTRY 42
#define R_RISCV_ALIGN 43
#define R_RISCV_RVC_BRANCH 44
#define R_RISCV_RVC_JUMP 45
#define R_RISCV_RVC_LUI 46
#define R_RISCV_GPREL_I 47
#define R_RISCV_GPREL_S 48
#define R_RISCV_TPREL_I 49
#define R_RISCV_TPREL_S 50
#define R_RISCV_RELAX 51
#define R_RISCV_SUB6 52
#define R_RISCV_SET6 53
#define R_RISCV_SET8 54
#define R_RISCV_SET16 55
#define R_RISCV_SET32 56
#define R_RISCV_32_PCREL 57
#endif /* __ARCH_RISCV_INCLUDE_ELF_H */
+1 -1
View File
@@ -152,7 +152,7 @@ static void elf_dumploadinfo(FAR struct elf_loadinfo_s *loadinfo)
{
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
binfo("Sections %d:\n", i);
binfo(" sh_name: %08x\n", shdr->sh_name);
binfo(" sh_type: %08x\n", shdr->sh_type);
+6
View File
@@ -3,6 +3,12 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config ELF_64BIT
bool "64bit ELF support"
default n
---help---
This option is used to load 64bit ELF files
config ELF_ALIGN_LOG2
int "Log2 Section Alignment"
default 2
+3 -3
View File
@@ -64,7 +64,7 @@
*
****************************************************************************/
int elf_verifyheader(FAR const Elf32_Ehdr *header);
int elf_verifyheader(FAR const Elf_Ehdr *header);
/****************************************************************************
* Name: elf_read
@@ -150,7 +150,7 @@ int elf_findsymtab(FAR struct elf_loadinfo_s *loadinfo);
****************************************************************************/
int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym);
FAR Elf_Sym *sym);
/****************************************************************************
* Name: elf_symvalue
@@ -177,7 +177,7 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
*
****************************************************************************/
int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf_Sym *sym,
FAR const struct symtab_s *exports, int nexports);
/****************************************************************************
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -88,7 +88,7 @@
int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
{
FAR Elf32_Shdr *shdr;
FAR Elf_Shdr *shdr;
size_t ctorsize;
int ctoridx;
int ret;
+1 -1
View File
@@ -88,7 +88,7 @@
int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
{
FAR Elf32_Shdr *shdr;
FAR Elf_Shdr *shdr;
size_t dtorsize;
int dtoridx;
int ret;
+2 -2
View File
@@ -173,7 +173,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
/* Read the ELF ehdr from offset 0 */
ret = elf_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr,
sizeof(Elf32_Ehdr), 0);
sizeof(Elf_Ehdr), 0);
if (ret < 0)
{
berr("Failed to read ELF header: %d\n", ret);
@@ -182,7 +182,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
}
elf_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,
sizeof(Elf32_Ehdr));
sizeof(Elf_Ehdr));
/* Verify the ELF header */
+4 -3
View File
@@ -106,7 +106,7 @@ static void elf_elfsize(struct elf_loadinfo_s *loadinfo)
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
/* SHF_ALLOC indicates that the section requires memory during
* execution.
@@ -164,7 +164,7 @@ static inline int elf_loadfile(FAR struct elf_loadinfo_s *loadinfo)
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
/* SHF_ALLOC indicates that the section requires memory during
* execution.
@@ -286,7 +286,8 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo)
/* Allocate (and zero) memory for the ELF file. */
ret = elf_addrenv_alloc(loadinfo, loadinfo->textsize, loadinfo->datasize, heapsize);
ret = elf_addrenv_alloc(loadinfo, loadinfo->textsize, loadinfo->datasize,
heapsize);
if (ret < 0)
{
berr("ERROR: elf_addrenv_alloc() failed: %d\n", ret);
+4 -4
View File
@@ -75,9 +75,9 @@
****************************************************************************/
static inline int elf_sectname(FAR struct elf_loadinfo_s *loadinfo,
FAR const Elf32_Shdr *shdr)
FAR const Elf_Shdr *shdr)
{
FAR Elf32_Shdr *shstr;
FAR Elf_Shdr *shstr;
FAR uint8_t *buffer;
off_t offset;
size_t readlen;
@@ -210,7 +210,7 @@ int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
/* Allocate memory to hold a working copy of the sector header table */
loadinfo->shdr = (FAR FAR Elf32_Shdr *)kmm_malloc(shdrsize);
loadinfo->shdr = (FAR FAR Elf_Shdr *)kmm_malloc(shdrsize);
if (!loadinfo->shdr)
{
berr("Failed to allocate the section header table. Size: %ld\n",
@@ -249,7 +249,7 @@ int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
int elf_findsection(FAR struct elf_loadinfo_s *loadinfo,
FAR const char *sectname)
{
FAR const Elf32_Shdr *shdr;
FAR const Elf_Shdr *shdr;
int ret;
int i;
+10 -9
View File
@@ -78,7 +78,7 @@
****************************************************************************/
static int elf_symname(FAR struct elf_loadinfo_s *loadinfo,
FAR const Elf32_Sym *sym)
FAR const Elf_Sym *sym)
{
FAR uint8_t *buffer;
off_t offset;
@@ -215,14 +215,14 @@ int elf_findsymtab(FAR struct elf_loadinfo_s *loadinfo)
****************************************************************************/
int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym)
FAR Elf_Sym *sym)
{
FAR Elf32_Shdr *symtab = &loadinfo->shdr[loadinfo->symtabidx];
FAR Elf_Shdr *symtab = &loadinfo->shdr[loadinfo->symtabidx];
off_t offset;
/* Verify that the symbol table index lies within symbol table */
if (index < 0 || index > (symtab->sh_size / sizeof(Elf32_Sym)))
if (index < 0 || index > (symtab->sh_size / sizeof(Elf_Sym)))
{
berr("Bad relocation symbol index: %d\n", index);
return -EINVAL;
@@ -230,11 +230,11 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
/* Get the file offset to the symbol table entry */
offset = symtab->sh_offset + sizeof(Elf32_Sym) * index;
offset = symtab->sh_offset + sizeof(Elf_Sym) * index;
/* And, finally, read the symbol table entry into memory */
return elf_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf32_Sym), offset);
return elf_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf_Sym), offset);
}
/****************************************************************************
@@ -260,7 +260,7 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
*
****************************************************************************/
int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf_Sym *sym,
FAR const struct symtab_s *exports, int nexports)
{
FAR const struct symtab_s *symbol;
@@ -314,7 +314,8 @@ int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
#endif
if (!symbol)
{
berr("SHN_UNDEF: Exported symbol \"%s\" not found\n", loadinfo->iobuffer);
berr("SHN_UNDEF: Exported symbol \"%s\" not found\n",
loadinfo->iobuffer);
return -ENOENT;
}
@@ -324,7 +325,7 @@ int elf_symvalue(FAR struct elf_loadinfo_s *loadinfo, FAR Elf32_Sym *sym,
loadinfo->iobuffer, sym->st_value, symbol->sym_value,
sym->st_value + symbol->sym_value);
sym->st_value += (Elf32_Word)((uintptr_t)symbol->sym_value);
sym->st_value += (Elf_Word)((uintptr_t)symbol->sym_value);
}
break;
+1 -1
View File
@@ -84,7 +84,7 @@ static const char g_elfmagic[EI_MAGIC_SIZE] =
*
****************************************************************************/
int elf_verifyheader(FAR const Elf32_Ehdr *ehdr)
int elf_verifyheader(FAR const Elf_Ehdr *ehdr)
{
if (!ehdr)
{
@@ -0,0 +1,59 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="maix-bit"
CONFIG_ARCH_BOARD_MAIX_BIT=y
CONFIG_ARCH_CHIP="k210"
CONFIG_ARCH_CHIP_K210=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_APP_SYMTAB=y
CONFIG_BOARD_LOOPSPERMSEC=46000
CONFIG_BUILTIN=y
CONFIG_CXX_NEWLONG=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_ELF_64BIT=y
CONFIG_ELF_ALIGN_LOG2=3
CONFIG_EXAMPLES_ELF=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_LIB_BOARDCTL=y
CONFIG_LIB_ENVPATH=y
CONFIG_MAX_TASKS=64
CONFIG_MAX_WDOGPARMS=2
CONFIG_NFILE_STREAMS=8
CONFIG_PATH_INITIAL="/mnt/romfs"
CONFIG_PIPES=y
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=3072
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=2097152
CONFIG_RAM_START=0x80400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=5
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2020
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_TASK_NAME_SIZE=20
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=3072
CONFIG_USER_ENTRYPOINT="elf_main"
CONFIG_WDOG_INTRESERVE=0
@@ -0,0 +1,61 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="maix-bit"
CONFIG_ARCH_BOARD_MAIX_BIT=y
CONFIG_ARCH_CHIP="k210"
CONFIG_ARCH_CHIP_K210=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_APP_SYMTAB=y
CONFIG_BOARD_LOOPSPERMSEC=46000
CONFIG_BUILTIN=y
CONFIG_CXX_NEWLONG=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_ELF_64BIT=y
CONFIG_ELF_ALIGN_LOG2=3
CONFIG_EXAMPLES_MODULE=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_LIB_BOARDCTL=y
CONFIG_LIB_ENVPATH=y
CONFIG_MAX_TASKS=64
CONFIG_MAX_WDOGPARMS=2
CONFIG_MODULE=y
CONFIG_NFILE_STREAMS=8
CONFIG_PATH_INITIAL="/mnt/romfs"
CONFIG_PIPES=y
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=3072
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=2097152
CONFIG_RAM_START=0x80400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=5
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2020
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_TASK_NAME_SIZE=20
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=3072
CONFIG_USER_ENTRYPOINT="module_main"
CONFIG_WDOG_INTRESERVE=0
@@ -0,0 +1,57 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="maix-bit"
CONFIG_ARCH_BOARD_MAIX_BIT=y
CONFIG_ARCH_CHIP="k210"
CONFIG_ARCH_CHIP_K210=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARDCTL_APP_SYMTAB=y
CONFIG_BOARD_LOOPSPERMSEC=46000
CONFIG_BUILTIN=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_ELF_64BIT=y
CONFIG_EXAMPLES_POSIXSPAWN=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_LIB_BOARDCTL=y
CONFIG_LIB_ENVPATH=y
CONFIG_MAX_TASKS=64
CONFIG_MAX_WDOGPARMS=2
CONFIG_NFILE_STREAMS=8
CONFIG_PATH_INITIAL="/mnt/romfs"
CONFIG_PIPES=y
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=2097152
CONFIG_RAM_START=0x80400000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=28
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2019
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_TASK_NAME_SIZE=20
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_USERMAIN_STACKSIZE=3072
CONFIG_USER_ENTRYPOINT="posix_spawn_main"
CONFIG_WDOG_INTRESERVE=0
@@ -94,10 +94,37 @@ CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS += $(CFLAGS) -D__ASSEMBLY__ $(ASARCHCPUFLAGS)
# NXFLAT module definitions
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
# Loadable module definitions
CMODULEFLAGS = $(CFLAGS)
LDMODULEFLAGS = -r -e module_initialize
ifeq ($(WINTOOL),y)
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
else
LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
endif
# ELF module definitions
CELFFLAGS = $(CFLAGS)
CXXELFFLAGS = $(CXXFLAGS)
LDELFFLAGS = -r -e main
ifeq ($(WINTOOL),y)
LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}"
else
LDELFFLAGS += -T $(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld
endif
# File extensions
ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
@@ -0,0 +1,115 @@
/****************************************************************************
* boards/risc-v/k210/maix-bit/scripts/gnu-elf.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
SECTIONS
{
.text 0x00000000 :
{
_stext = . ;
*(.text)
*(.text.*)
*(.gnu.warning)
*(.stub)
*(.glue_7)
*(.glue_7t)
*(.jcr)
/* C++ support: The .init and .fini sections contain specific logic
* to manage static constructors and destructors.
*/
*(.gnu.linkonce.t.*)
*(.init) /* Old ABI */
*(.fini) /* Old ABI */
_etext = . ;
}
.rodata :
{
_srodata = . ;
*(.rodata)
*(.rodata1)
*(.rodata.*)
*(.gnu.linkonce.r*)
_erodata = . ;
}
.data :
{
_sdata = . ;
*(.data)
*(.data1)
*(.data.*)
*(.gnu.linkonce.d*)
. = ALIGN(4);
_edata = . ;
}
/* C++ support. For each global and static local C++ object,
* GCC creates a small subroutine to construct the object. Pointers
* to these routines (not the routines themselves) are stored as
* simple, linear arrays in the .ctors section of the object file.
* Similarly, pointers to global/static destructor routines are
* stored in .dtors.
*/
.ctors :
{
_sctors = . ;
*(.ctors) /* Old ABI: Unallocated */
*(.init_array) /* New ABI: Allocated */
_edtors = . ;
}
.dtors :
{
_sdtors = . ;
*(.dtors) /* Old ABI: Unallocated */
*(.fini_array) /* New ABI: Allocated */
_edtors = . ;
}
.bss :
{
_sbss = . ;
*(.bss)
*(.bss.*)
*(.sbss)
*(.sbss.*)
*(.gnu.linkonce.b*)
*(COMMON)
_ebss = . ;
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}
+222
View File
File diff suppressed because it is too large Load Diff
+8 -185
View File
File diff suppressed because it is too large Load Diff
+157
View File
@@ -0,0 +1,157 @@
/****************************************************************************
* include/elf64.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_ELF64_H
#define __INCLUDE_ELF64_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <elf.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* See ELF-64 Object File Format: Version 1.5 Draft 2 */
/* Definitions for Elf64_Rel*::r_info */
#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i) & 0xffffffffL)
#define ELF64_R_INFO(s,t) (((s)<< 32) + ((t) & 0xffffffffL))
#define ELF_R_SYM(i) ELF64_R_SYM(i)
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* Table 1: ELF-64 Data Types */
typedef uint64_t Elf64_Addr; /* Unsigned program address */
typedef uint64_t Elf64_Off; /* Unsigned file offset */
typedef uint16_t Elf64_Half; /* Unsigned medium integer */
typedef uint32_t Elf64_Word; /* Unsigned long integer */
typedef int32_t Elf64_Sword; /* Signed integer */
typedef uint64_t Elf64_Xword; /* Unsigned long integer */
typedef int64_t Elf64_Sxword; /* Signed large integer */
/* Figure 2: ELF-64 Header */
typedef struct
{
unsigned char e_ident[EI_NIDENT]; /* ELF identification */
Elf64_Half e_type; /* Object file type */
Elf64_Half e_machine; /* Machine type */
Elf64_Word e_version; /* Object file version */
Elf64_Addr e_entry; /* Entry point address */
Elf64_Off e_phoff; /* Program header offset */
Elf64_Off e_shoff; /* Section header offset */
Elf64_Word e_flags; /* Processor-specific flags */
Elf64_Half e_ehsize; /* ELF header size */
Elf64_Half e_phentsize; /* Size of program header entry */
Elf64_Half e_phnum; /* Number of program header entry */
Elf64_Half e_shentsize; /* Size of section header entry */
Elf64_Half e_shnum; /* Number of section header entries */
Elf64_Half e_shstrndx; /* Section name string table index */
} Elf64_Ehdr;
/* Figure 3: ELF-64 Section Header */
typedef struct
{
Elf64_Word sh_name; /* Section name */
Elf64_Word sh_type; /* Section type */
Elf64_Xword sh_flags; /* Section attributes */
Elf64_Addr sh_addr; /* Virtual address in memory */
Elf64_Off sh_offset; /* Offset in file */
Elf64_Xword sh_size; /* Size of section */
Elf64_Word sh_link; /* Link to other section */
Elf64_Word sh_info; /* Miscellaneous information */
Elf64_Xword sh_addralign; /* Address alignment boundary */
Elf64_Xword sh_entsize; /* Size of entries, if section has table */
} Elf64_Shdr;
/* Figure 4: ELF-64 Symbol Table Entry */
typedef struct
{
Elf64_Word st_name; /* Symbol name */
unsigned char st_info; /* Type and Binding attributes */
unsigned char st_other; /* Reserved */
Elf64_Half st_shndx; /* Section table index */
Elf64_Addr st_value; /* Symbol value */
Elf64_Xword st_size; /* Size of object (e.g., common) */
} Elf64_Sym;
/* Figure 5: ELF-64 Relocation Entries */
typedef struct
{
Elf64_Addr r_offset; /* Address of reference */
Elf64_Xword r_info; /* Symbol index and type of relocation */
} Elf64_Rel;
typedef struct
{
Elf64_Addr r_offset; /* Address of reference */
Elf64_Xword r_info; /* Symbol index and type of relocation */
Elf64_Sxword r_addend; /* Constant part of expression */
} Elf64_Rela;
/* Figure 6: ELF-64 Program Header Table Entry */
typedef struct
{
Elf64_Word p_type; /* Type of segment */
Elf64_Word p_flags; /* Segment attributes */
Elf64_Off p_offset; /* Offset in file */
Elf64_Addr p_vaddr; /* Virtual address in memory */
Elf64_Addr p_paddr; /* Reserved */
Elf64_Word p_filesz; /* Size of segment in file */
Elf64_Word p_memsz; /* Size of segment in memory */
Elf64_Word p_align; /* Alignment of segment */
} Elf64_Phdr;
/* Figure 8: Dynamic Table Structure */
typedef struct
{
Elf64_Sxword d_tag;
union
{
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
typedef Elf64_Ehdr Elf_Ehdr;
typedef Elf64_Rel Elf_Rel;
typedef Elf64_Rela Elf_Rela;
typedef Elf64_Sym Elf_Sym;
typedef Elf64_Shdr Elf_Shdr;
typedef Elf64_Word Elf_Word;
#endif /* __INCLUDE_ELF64_H */
+7 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/binfmt/elf.h
*
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014, 2020 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <elf32.h>
#include <elf.h>
#include <nuttx/arch.h>
#include <nuttx/binfmt/binfmt.h>
@@ -54,6 +54,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_ELF_ALIGN_LOG2
@@ -110,8 +111,9 @@ struct elf_loadinfo_s
size_t textsize; /* Size of the ELF .text memory allocation */
size_t datasize; /* Size of the ELF .bss/.data memory allocation */
off_t filelen; /* Length of the entire ELF file */
Elf32_Ehdr ehdr; /* Buffered ELF file header */
FAR Elf32_Shdr *shdr; /* Buffered ELF section headers */
Elf_Ehdr ehdr; /* Buffered ELF file header */
FAR Elf_Shdr *shdr; /* Buffered ELF section headers */
uint8_t *iobuffer; /* File I/O buffer */
/* Constructors and destructors */
@@ -145,7 +147,7 @@ struct elf_loadinfo_s
};
/****************************************************************************
* Public Functions
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
+6 -6
View File
@@ -40,7 +40,7 @@
* Included Files
****************************************************************************/
#include <elf32.h>
#include <elf.h>
/****************************************************************************
* Public Function Prototypes
@@ -68,7 +68,7 @@ extern "C"
****************************************************************************/
#ifdef CONFIG_LIBC_ARCH_ELF
bool up_checkarch(FAR const Elf32_Ehdr *hdr);
bool up_checkarch(FAR const Elf_Ehdr *hdr);
#endif
/****************************************************************************
@@ -94,10 +94,10 @@ bool up_checkarch(FAR const Elf32_Ehdr *hdr);
****************************************************************************/
#ifdef CONFIG_LIBC_ARCH_ELF
int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
int up_relocate(FAR const Elf_Rel *rel, FAR const Elf_Sym *sym,
uintptr_t addr);
int up_relocateadd(FAR const Elf32_Rela *rel,
FAR const Elf32_Sym *sym, uintptr_t addr);
int up_relocateadd(FAR const Elf_Rela *rel,
FAR const Elf_Sym *sym, uintptr_t addr);
#endif
/****************************************************************************
@@ -117,7 +117,7 @@ int up_relocateadd(FAR const Elf32_Rela *rel,
****************************************************************************/
#ifdef CONFIG_CXX_EXCEPTION
int up_init_exidx(Elf32_Addr address, Elf32_Word size);
int up_init_exidx(Elf_Addr address, Elf_Word size);
#endif
#if defined(__cplusplus)
+6 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/lib/modlib.h
*
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017, 2020 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <elf32.h>
#include <elf.h>
#include <nuttx/arch.h>
#include <nuttx/symtab.h>
@@ -51,6 +51,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_MODLIB_MAXDEPEND
@@ -126,7 +127,7 @@ typedef CODE int (*mod_uninitializer_t)(FAR void *arg);
* be returned if no uninitialization is needed (i.e, the
* the module memory can be deallocated at any time).
* arg - An argument that will be passed to the uninitialization
function.
* function.
* exports - A symbol table exported by the module
* nexports - The number of symbols in the exported symbol table.
*/
@@ -206,8 +207,8 @@ struct mod_loadinfo_s
size_t textsize; /* Size of the module .text memory allocation */
size_t datasize; /* Size of the module .bss/.data memory allocation */
off_t filelen; /* Length of the entire module file */
Elf32_Ehdr ehdr; /* Buffered module file header */
FAR Elf32_Shdr *shdr; /* Buffered module section headers */
Elf_Ehdr ehdr; /* Buffered module file header */
FAR Elf_Shdr *shdr; /* Buffered module section headers */
uint8_t *iobuffer; /* File I/O buffer */
uint16_t symtabidx; /* Symbol table section index */
+1 -1
View File
@@ -98,7 +98,7 @@ static void dldump_loadinfo(FAR struct mod_loadinfo_s *loadinfo)
{
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
binfo("Sections %d:\n", i);
binfo(" sh_name: %08x\n", shdr->sh_name);
binfo(" sh_type: %08x\n", shdr->sh_type);
+3
View File
@@ -153,6 +153,9 @@ config LIBM_ARCH_TRUNCF
if ARCH_ARM
source libs/libc/machine/arm/Kconfig
endif
if ARCH_RISCV
source libs/libc/machine/risc-v/Kconfig
endif
if ARCH_SIM
source libs/libc/machine/sim/Kconfig
endif
+3
View File
@@ -36,6 +36,9 @@
ifeq ($(CONFIG_ARCH_ARM),y)
include ${TOPDIR}/libs/libc/machine/arm/Make.defs
endif
ifeq ($(CONFIG_ARCH_RISCV),y)
include ${TOPDIR}/libs/libc/machine/risc-v/Make.defs
endif
ifeq ($(CONFIG_ARCH_SIM),y)
include ${TOPDIR}/libs/libc/machine/sim/Make.defs
endif
+9
View File
@@ -0,0 +1,9 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_RV64GC
source libs/libc/machine/risc-v/rv64/Kconfig
endif
+23
View File
@@ -0,0 +1,23 @@
############################################################################
# libs/libc/machine/arm/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifeq ($(CONFIG_ARCH_RV64GC),y)
include ${TOPDIR}/libs/libc/machine/risc-v/rv64/Make.defs
endif
+4
View File
@@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
+28
View File
@@ -0,0 +1,28 @@
############################################################################
# libs/libc/machine/risc-v/rv64/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifeq ($(CONFIG_LIBC_ARCH_ELF),y)
CSRCS += arch_elf.c
DEPPATH += --dep-path machine/risc-v/rv64
VPATH += :machine/risc-v/rv64
endif
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -64,7 +64,7 @@
*
****************************************************************************/
int modlib_verifyheader(FAR const Elf32_Ehdr *header);
int modlib_verifyheader(FAR const Elf_Ehdr *header);
/****************************************************************************
* Name: modlib_findsymtab
@@ -98,7 +98,7 @@ int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo);
****************************************************************************/
int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym);
FAR Elf_Sym *sym);
/****************************************************************************
* Name: modlib_symvalue
@@ -125,7 +125,7 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
****************************************************************************/
int modlib_symvalue(FAR struct module_s *modp,
FAR struct mod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym);
FAR struct mod_loadinfo_s *loadinfo, FAR Elf_Sym *sym);
/****************************************************************************
* Name: modlib_loadshdrs
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -170,7 +170,7 @@ int modlib_initialize(FAR const char *filename,
/* Read the ELF ehdr from offset 0 */
ret = modlib_read(loadinfo, (FAR uint8_t *)&loadinfo->ehdr,
sizeof(Elf32_Ehdr), 0);
sizeof(Elf_Ehdr), 0);
if (ret < 0)
{
berr("ERROR: Failed to read ELF header: %d\n", ret);
@@ -178,7 +178,7 @@ int modlib_initialize(FAR const char *filename,
}
modlib_dumpbuffer("ELF header", (FAR const uint8_t *)&loadinfo->ehdr,
sizeof(Elf32_Ehdr));
sizeof(Elf_Ehdr));
/* Verify the ELF header */
+2 -2
View File
@@ -99,7 +99,7 @@ static void modlib_elfsize(struct mod_loadinfo_s *loadinfo)
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
/* SHF_ALLOC indicates that the section requires memory during
* execution.
@@ -157,7 +157,7 @@ static inline int modlib_loadfile(FAR struct mod_loadinfo_s *loadinfo)
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
/* SHF_ALLOC indicates that the section requires memory during
* execution */
+4 -4
View File
@@ -67,9 +67,9 @@
****************************************************************************/
static inline int modlib_sectname(FAR struct mod_loadinfo_s *loadinfo,
FAR const Elf32_Shdr *shdr)
FAR const Elf_Shdr *shdr)
{
FAR Elf32_Shdr *shstr;
FAR Elf_Shdr *shstr;
FAR uint8_t *buffer;
off_t offset;
size_t readlen;
@@ -203,7 +203,7 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
/* Allocate memory to hold a working copy of the sector header table */
loadinfo->shdr = (FAR FAR Elf32_Shdr *)lib_malloc(shdrsize);
loadinfo->shdr = (FAR FAR Elf_Shdr *)lib_malloc(shdrsize);
if (!loadinfo->shdr)
{
berr("ERROR: Failed to allocate the section header table. Size: %ld\n",
@@ -243,7 +243,7 @@ int modlib_loadshdrs(FAR struct mod_loadinfo_s *loadinfo)
int modlib_findsection(FAR struct mod_loadinfo_s *loadinfo,
FAR const char *sectname)
{
FAR const Elf32_Shdr *shdr;
FAR const Elf_Shdr *shdr;
int ret;
int i;
+8 -8
View File
@@ -89,7 +89,7 @@ struct mod_exportinfo_s
****************************************************************************/
static int modlib_symname(FAR struct mod_loadinfo_s *loadinfo,
FAR const Elf32_Sym *sym)
FAR const Elf_Sym *sym)
{
FAR uint8_t *buffer;
off_t offset;
@@ -276,14 +276,14 @@ int modlib_findsymtab(FAR struct mod_loadinfo_s *loadinfo)
****************************************************************************/
int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
FAR Elf32_Sym *sym)
FAR Elf_Sym *sym)
{
FAR Elf32_Shdr *symtab = &loadinfo->shdr[loadinfo->symtabidx];
FAR Elf_Shdr *symtab = &loadinfo->shdr[loadinfo->symtabidx];
off_t offset;
/* Verify that the symbol table index lies within symbol table */
if (index < 0 || index > (symtab->sh_size / sizeof(Elf32_Sym)))
if (index < 0 || index > (symtab->sh_size / sizeof(Elf_Sym)))
{
berr("ERROR: Bad relocation symbol index: %d\n", index);
return -EINVAL;
@@ -291,11 +291,11 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
/* Get the file offset to the symbol table entry */
offset = symtab->sh_offset + sizeof(Elf32_Sym) * index;
offset = symtab->sh_offset + sizeof(Elf_Sym) * index;
/* And, finally, read the symbol table entry into memory */
return modlib_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf32_Sym), offset);
return modlib_read(loadinfo, (FAR uint8_t *)sym, sizeof(Elf_Sym), offset);
}
/****************************************************************************
@@ -323,7 +323,7 @@ int modlib_readsym(FAR struct mod_loadinfo_s *loadinfo, int index,
****************************************************************************/
int modlib_symvalue(FAR struct module_s *modp,
FAR struct mod_loadinfo_s *loadinfo, FAR Elf32_Sym *sym)
FAR struct mod_loadinfo_s *loadinfo, FAR Elf_Sym *sym)
{
FAR const struct symtab_s *symbol;
struct mod_exportinfo_s exportinfo;
@@ -416,7 +416,7 @@ int modlib_symvalue(FAR struct module_s *modp,
loadinfo->iobuffer, sym->st_value, symbol->sym_value,
sym->st_value + symbol->sym_value);
sym->st_value += (Elf32_Word)((uintptr_t)symbol->sym_value);
sym->st_value += (Elf_Word)((uintptr_t)symbol->sym_value);
}
break;
+1 -1
View File
@@ -77,7 +77,7 @@ static const char g_modmagic[EI_MAGIC_SIZE] =
*
****************************************************************************/
int modlib_verifyheader(FAR const Elf32_Ehdr *ehdr)
int modlib_verifyheader(FAR const Elf_Ehdr *ehdr)
{
if (!ehdr)
{
+1 -1
View File
@@ -85,7 +85,7 @@
extern "C"
{
int up_init_exidx(Elf32_Addr start, Elf32_Word size)
int up_init_exidx(Elf_Addr start, Elf_Word size)
{
__exidx_start_elf = (__EIT_entry *) start;
__exidx_end_elf = __exidx_start_elf + size;
+1 -1
View File
@@ -106,7 +106,7 @@ static void mod_dumploadinfo(FAR struct mod_loadinfo_s *loadinfo)
{
for (i = 0; i < loadinfo->ehdr.e_shnum; i++)
{
FAR Elf32_Shdr *shdr = &loadinfo->shdr[i];
FAR Elf_Shdr *shdr = &loadinfo->shdr[i];
binfo("Sections %d:\n", i);
binfo(" sh_name: %08x\n", shdr->sh_name);
binfo(" sh_type: %08x\n", shdr->sh_type);