Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add arm-nacl port.
  • Loading branch information
Roland McGrath committed Apr 17, 2015
1 parent f709259 commit d1e44df
Show file tree
Hide file tree
Showing 127 changed files with 5,120 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,3 +1,10 @@
2015-04-17 Roland McGrath <roland@hack.frob.com>

Add preliminary port to Google Native Client on ARM.
* abi-tags (.*-.*-nacl.*): New entry.
* sysdeps/arm/nacl: New directory.
* sysdeps/nacl: New directory.

2015-04-16 David S. Miller <davem@davemloft.net>

* sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Make use of
Expand Down
2 changes: 2 additions & 0 deletions abi-tags
Expand Up @@ -28,5 +28,7 @@

.*-.*-syllable.* 5 2.0.0 # just an arbitrary value

.*-.*-nacl.* 6 42.0.0 # earliest compatible Chromium version

# There is no catch-all default here because every supported OS that uses
# ELF must have its own unique ABI tag.
2 changes: 2 additions & 0 deletions sysdeps/arm/nacl/Implies
@@ -0,0 +1,2 @@
arm/nptl
init_array
33 changes: 33 additions & 0 deletions sysdeps/arm/nacl/Makefile
@@ -0,0 +1,33 @@
# Makefile fragment for ARM/NaCl configurations.

# Copyright (C) 2015 Free Software Foundation, Inc.
# This file is part of the GNU C Library.

# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.

# sysdeps/nacl/Makefile needs this set to the architecture suffix used in
# the NaCl SDK.
nacl-sdk-arch = arm

# We don't really support TLSDESC, even though the compiler thinks it does.
have-arm-tls-desc = no

ifeq ($(subdir),csu)
sysdep_routines += aeabi_read_tp
endif

ifeq ($(subdir),elf)
sysdep-rtld-routines += aeabi_read_tp
endif
47 changes: 47 additions & 0 deletions sysdeps/arm/nacl/____longjmp_chk.S
@@ -0,0 +1,47 @@
/* longjmp that validates stack addresses. ARM/NaCl version.
Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */

#include <sysdep.h>

.section .rodata.str1.1,"aMS",%progbits,1
.type longjmp_msg,%object
longjmp_msg:
.string "longjmp causes uninitialized stack frame"
.size longjmp_msg, .-longjmp_msg

.text

/* We don't have sigaltstack and so any longjmp must be to an outer frame. */
.macro check_sp reg
cmp sp, \reg
bls .Lok
#ifdef PIC
movw r0, #:lower16:longjmp_msg-(.LPIC0+8)
movt r0, #:upper16:longjmp_msg-(.LPIC0+8)
.LPIC0: add r0, r0, pc
#else
movw r0, #:lower16:longjmp_msg
movt r0, #:upper16:longjmp_msg
#endif
b HIDDEN_JUMPTARGET(__fortify_fail)
.Lok:
.endm

#define CHECK_SP(reg) check_sp reg
#define __longjmp ____longjmp_chk
#include <__longjmp.S>
44 changes: 44 additions & 0 deletions sysdeps/arm/nacl/aeabi_read_tp.S
@@ -0,0 +1,44 @@
/* ARM EABI helper function for reading the thread pointer. NaCl version.
Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
In addition to the permissions in the GNU Lesser General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file with other
programs, and to distribute those programs without any restriction
coming from the use of this file. (The GNU Lesser General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into another program.)
Note that people who make modified versions of this file are not
obligated to grant this special exception for their modified
versions; it is their choice whether to do so. The GNU Lesser
General Public License gives permission to release a modified
version without this exception; this exception also makes it
possible to release a modified version which carries forward this
exception.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */

#include <sysdep.h>

/* GCC will emit calls to this routine under -mtp=soft. */

.hidden __aeabi_read_tp
ENTRY (__aeabi_read_tp)
ldr r0, [r9]
sfi_bx lr
END (__aeabi_read_tp)
43 changes: 43 additions & 0 deletions sysdeps/arm/nacl/arm-features.h
@@ -0,0 +1,43 @@
/* Macros to test for CPU features on ARM. NaCl version.
Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */

#ifndef _NACL_ARM_FEATURES_H
#define _NACL_ARM_FEATURES_H 1

#ifdef __SOFTFP__
# error NaCl should always have VFP enabled
#endif

/* NaCl does not support iWMMXt at all. */
#define ARM_ASSUME_NO_IWMMXT 1

/* NaCl does not allow instructions to target the pc register. */
#define ARM_ALWAYS_BX 1

/* Computed branch targets must be bundle-aligned, which is to 16 bytes. */
#define ARM_BX_ALIGN_LOG2 4

/* Two-register addressing modes are never allowed. */
#define ARM_NO_INDEX_REGISTER 1

/* Only ARM mode code is allowed, never Thumb mode. */
#define NO_THUMB

#include_next <arm-features.h>

#endif /* arm-features.h */
53 changes: 53 additions & 0 deletions sysdeps/arm/nacl/dl-machine.h
@@ -0,0 +1,53 @@
/* Machine-dependent ELF dynamic relocation inline functions. ARM/NaCl version.
Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */

#ifndef dl_machine_h

/* This is only needed for handling TEXTRELs and NaCl will never
support TEXTRELs at all. */
#define CLEAR_CACHE(start, end) __builtin_trap ()

#endif

/* The rest is just machine-specific.
This #include is outside the #ifndef because the parts of
dl-machine.h used only by dynamic-link.h are outside the guard. */
#include <sysdeps/arm/dl-machine.h>

#ifdef dl_machine_h

/* Initial entry point code for the dynamic linker.
The C function `_dl_start' is the real entry point;
its return value is the user program's entry point. */
#undef RTLD_START
#define RTLD_START asm ("\
.text\n\
.globl _start\n\
.type _start, %function\n\
.p2align 4\n\
_start:\n\
@ r0 has the pointer to the info block (see nacl_startup.h)\n\
mov r1, sp @ Save stack base for __libc_stack_end.\n\
push {r0-r3} @ Push those, maintaining alignment to 16.\n\
mov r0, sp @ Pointer to {info, sp} is argument.\n\
sfi_bl _dl_start\n\
pop {r1-r4} @ Restore stack, getting info block into r1.\n\
mov lr, #0 @ Return address for noreturn call.\n\
b _dl_start_user");

#endif

0 comments on commit d1e44df

Please sign in to comment.