Compare commits

..

225 Commits

Author SHA1 Message Date
The Android Automerger
63d2f6db2e merge in lmp-mr1-release history after reset to lmp-mr1-dev 2015-02-04 06:08:53 -08:00
Neil Fuller
4177bd8d16 Fixes to the update-tzdata.py tool
We build one too many times. Creating a missing directory
is sufficient.

The tz2icu needs some files in the CWD. Added symlinks.

Bug: 19230091
(cherry-pick of commit 0662c3e5b3)
Change-Id: Ie21d848f1b776ec745473b9122e003fdf0acf105
2015-02-02 17:53:19 +00:00
Neil Fuller
700eb048fb Update tzdata to tzdata2015a
Time Zone Data v. 2015a (Released 2015-01-29)
http://www.iana.org/time-zones/repository/releases/tzdata2015a.tar.gz

Information from NEWS:

Release 2015a - 2015-01-29 22:35:20 -0800

  Changes affecting future time stamps

    The Mexican state of Quintana Roo, represented by America/Cancun,
    will shift from Central Time with DST to Eastern Time without DST
    on 2015-02-01 at 02:00.  (Thanks to Steffen Thorsen and Gwillim Law.)

    Chile will not change clocks in April or thereafter; its new standard time
    will be its old daylight saving time.  This affects America/Santiago,
    Pacific/Easter, and Antarctica/Palmer.  (Thanks to Juan Correa.)

    New leap second 2015-06-30 23:59:60 UTC as per IERS Bulletin C 49.
    (Thanks to Tim Parenti.)

  Changes affecting past time stamps

    Iceland observed DST in 1919 and 1921, and its 1939 fallback
    transition was Oct. 29, not Nov. 29.  Remove incorrect data from
    Shanks about time in Iceland between 1837 and 1908.

    Some more zones have been turned into links, when they differed
    from existing zones only for older time stamps.  As usual,
    these changes affect UTC offsets in pre-1970 time stamps only.
    Their old contents have been moved to the 'backzone' file.
    The affected zones are: Asia/Aden, Asia/Bahrain, Asia/Kuwait,
    and Asia/Muscat.

  Changes affecting code

    tzalloc now scrubs time zone abbreviations compatibly with the way
    that tzset always has, by replacing invalid bytes with '_' and by
    shortening too-long abbreviations.

    tzselect ports to POSIX awk implementations, no longer mishandles
    POSIX TZ settings when GNU awk is used, and reports POSIX TZ
    settings to the user.  (Thanks to Stefan Kuhn.)

  Changes affecting build procedure

    'make check' now checks for links to links in the data.
    One such link (for Africa/Asmera) has been fixed.
    (Thanks to Stephen Colebourne for pointing out the problem.)

  Changes affecting commentary

    The leapseconds file commentary now mentions the expiration date.
    (Problem reported by Martin Burnicki.)

    Update Mexican Library of Congress URL.

Bug: 19212588
Change-Id: Idc07ac862901500d4a1dbd0f4aadcfd0aa9d10b8
2015-02-02 11:32:10 +00:00
The Android Automerger
f0b38a3fc9 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2015-01-08 09:31:57 -08:00
Dmitriy Ivanov
d9e211ca1f Print error when prelink fails for main executable
Bug: 18931021
Change-Id: Ieefdcf60f1506af522714300030754a4ed61c08e
2015-01-07 11:23:34 -08:00
The Android Automerger
ecb7dcc084 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-12-08 06:09:01 -08:00
Elliott Hughes
c7450f7738 Restore symbols from <arpa/nameser.h>.
Bug: 18627252
Bug: https://code.google.com/p/android/issues/detail?id=81690

(cherry picked from commit 42804c4b30)

Change-Id: Idd33578b31bba9a4afdfd15c7b193d10974aea90
2014-12-04 13:45:22 -08:00
The Android Automerger
f6f04b82e2 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-12-03 06:08:43 -08:00
Elliott Hughes
27d276f3a6 Avoid pathological behavior in OpenBSD's fread.
(cherry picked from commit 20841a137b)

Bug: https://code.google.com/p/android/issues/detail?id=81155
Bug: 18556607
Change-Id: Ibdfebc20dce4c34ad565014523c9b074e90ea665
2014-12-02 14:54:52 -08:00
Elliott Hughes
152e978f73 Merge "Put stdin/stdout/stderr symbols in place." into lmp-mr1-dev 2014-12-02 18:56:50 +00:00
The Android Automerger
25726c8ce4 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-12-02 06:08:56 -08:00
Elliott Hughes
111461aaae Put stdin/stdout/stderr symbols in place.
To help with future binary compatibility.

Bug: 18553223
Change-Id: Ia8103b4f189c18528b11948ac9e520f61b9ccc0e
2014-12-01 21:27:59 -08:00
Lorenzo Colitti
e5477f83b0 Fail queries fast if no DNS servers are configured.
When no DNS servers are configured (and thus there is no chance
that the DNS query will suceed), res_nsend returns early, but
it does not tell the cache that the query has failed.
Therefore, if the caller retries the query, it will block for
PENDING_REQUEST_TIMEOUT (= 20 seconds) waiting for the "existing
query" (which isn't actually doing anything) to complete.

Bug: 18240188
Bug: 18327075
Change-Id: I0df13ff4a17ee65e640be96695a3af31b020963a
2014-12-01 20:03:25 +00:00
The Android Automerger
fffca9eb3d merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-11-24 06:09:01 -08:00
Elliott Hughes
432f645887 Fix flockfile(3) and friends for stdin/stdout/stderr too.
stdin/stdout/stderr are special; their mutexes are initialized by
__sinit. There's no unit test for this, because __sinit has already
been called by the time the first unit test runs, but you could
reproduce this failure with a trivial main() that calls flockfile
or ftrylockfile on one of the standard streams before otherwise
using stdio.

Bug: 18208568

(cherry picked from commit c48c3e4bb3)

Change-Id: Ia0c43ed4ac69daea8152aee9516415a6e3f8a042
2014-11-19 15:49:09 -08:00
The Android Automerger
d602328201 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-11-18 06:09:23 -08:00
The Android Automerger
fa06d6dba7 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-11-17 06:09:15 -08:00
Elliott Hughes
047d943ee9 sysconf(3) returns long.
On LP32, this makes no difference. Not an ABI change.

On LP64, results are going to be in %rax or x0 whether they're 32- or 64-bit,
and the only difference is going to be whether the top bits are clobbered.

(cherry picked from commit 60d84af172)

Bug: 18390956
Change-Id: I722461498bc5494e2972fb07d5189dffe76e8993
2014-11-14 15:37:49 -08:00
Daniel Rosenberg
4a50d8ead7 bionic: libc: Added path to vendor build properties file.
Signed-off-by: Daniel Rosenberg <drosen@google.com>

(cherry picked from commit 71d220c1de)

Bug: 18281574
Change-Id: I2843f23ecb4c4ca79b230d8041bbca02dbedeadc
2014-11-13 13:09:59 -08:00
The Android Automerger
5831077f76 merge in lmp-mr1-release history after reset to lmp-mr1-dev 2014-11-13 06:10:24 -08:00
Elliott Hughes
c05314a0b2 Merge "Fix tzdata update tools for 'backzone'." into lmp-mr1-dev 2014-11-12 17:19:57 +00:00
Elliott Hughes
1ca3350f4c Upgrade bionic to tzdata2014j.
From the release notes:

   Changes affecting current and future time stamps

     Turks & Caicos' switch from US eastern time to UTC-4 year-round
     did not occur on 2014-11-02 at 02:00.  It's currently scheduled
     for 2015-11-01 at 02:00.  (Thanks to Chris Walton.)

   Changes affecting past time stamps

     Many pre-1989 time stamps have been corrected for Asia/Seoul and
     Asia/Pyongyang, based on sources for the Korean-language Wikipedia
     entry for time in Korea.  (Thanks to Sanghyuk Jung.)  Also, no
     longer guess that Pyongyang mimicked Seoul time after World War II,
     as this is politically implausible.

     Some more zones have been turned into links, when they differed
     from existing zones only for older time stamps.  As usual,
     these changes affect UTC offsets in pre-1970 time stamps only.
     Their old contents have been moved to the 'backzone' file.
     The affected zones are: Africa/Addis_Ababa, Africa/Asmara,
     Africa/Dar_es_Salaam, Africa/Djibouti, Africa/Kampala,
     Africa/Mogadishu, Indian/Antananarivo, Indian/Comoro, and
     Indian/Mayotte.

Bug: 18330681

(cherry picked from commit b11d8e057c)

Change-Id: Ifd48e7446e400dccae3afd5cbef96ca843775477
2014-11-11 19:56:09 -08:00
Elliott Hughes
371dcc189f Fix tzdata update tools for 'backzone'.
To maintain the status quo, we need to pull in backzone file. This file
can't be built on its own, so the easiest fix is to give zic(1) all the
files at once.

We also now have a situation where we have links to links, so we need to
dereference them until we find actual data.

Bug: 18330681

(cherry picked from commit 2c2463bd30)

Change-Id: I654b80518a7144038d8b3ea7223f49e2b1d2ad13
2014-11-11 19:55:35 -08:00
The Android Automerger
5553ed1e85 merge in lmp-mr1-release history after reset to 9d3382d97a 2014-11-08 06:09:36 -08:00
The Android Automerger
4107b7d092 merge in lmp-mr1-release history after reset to 9d3382d97a 2014-11-06 06:09:56 -08:00
The Android Automerger
b8e430701e merge in lmp-mr1-release history after reset to 9d3382d97a 2014-11-05 06:09:40 -08:00
Dmitriy Ivanov
e4ae96ffd3 Revert "Fix dlsym() to take into account RTLD_GLOBAL/LOCAL"
This reverts commit c85e82dde5.

Bug: 18222321
Bug: 18211780
Change-Id: I32f4048bd5ea85dc8a3dfccce8cf141b241ab692
2014-11-04 14:07:46 -08:00
Dmitriy Ivanov
d84897d4a3 Revert "Add RTLD_NODELETE flag support"
This reverts commit c87f65d2cd.

Bug: 18222321
Bug: 18211780
Change-Id: I00252e26a28a41ab9f1e2dd3b32f0f80d86297f1
2014-11-04 14:07:46 -08:00
Dmitriy Ivanov
189ac9f142 Revert "Fix relocation to look for symbols in local group"
This reverts commit fd2747bb58.

Bug: 18222321
Bug: 18211780
Change-Id: I2d4ebab1e73b7277161af76b99f8249825b22d65
2014-11-04 14:07:46 -08:00
Dmitriy Ivanov
8bf7353b79 Revert "Remove unnecessary lookups during relocations"
This reverts commit 6442dbd3bc.

Bug: 18222321
Bug: 18211780
Change-Id: I87b18a32238a1f75afe56149221b6691f50d9f56
2014-11-04 14:07:46 -08:00
Dmitriy Ivanov
8b952f5552 Revert "Fix mips build"
This reverts commit bf3d5ef5fd.

Bug: 18222321
Bug: 18211780
Change-Id: I902ed888197b358c77303f1acb6d5ffd7ae6dcd3
2014-11-04 14:07:46 -08:00
Dmitriy Ivanov
86fdf8f09b Revert "Fix symbol lookup order during relocation"
This reverts commit 976402cca1.

Bug: 18222321
Bug: 18211780
Change-Id: Iafdd3d843db7b1cf288be9a0232022816622c944
2014-11-04 14:07:46 -08:00
Dmitriy Ivanov
b9f21a08f3 Revert "Fix arm64 and arm builds."
This reverts commit 445111a1c9.

Bug: 18222321
Bug: 18211780
Change-Id: I4fa9e1b63ec9b528f8bfed73c2ec15046c43a2fe
2014-11-04 14:07:46 -08:00
The Android Automerger
0c7105c69f merge in lmp-mr1-release history after reset to d18f4b2578 2014-11-04 06:09:42 -08:00
Dmitriy Ivanov
9d3382d97a Revert "Fix dlsym() to take into account RTLD_GLOBAL/LOCAL"
This reverts commit c85e82dde5.

Bug: 18222321
Bug: 18211780
Change-Id: I32f4048bd5ea85dc8a3dfccce8cf141b241ab692
2014-11-03 22:15:29 -08:00
Dmitriy Ivanov
69c5d108a5 Revert "Add RTLD_NODELETE flag support"
This reverts commit c87f65d2cd.

Bug: 18222321
Bug: 18211780
Change-Id: I00252e26a28a41ab9f1e2dd3b32f0f80d86297f1
2014-11-03 22:15:26 -08:00
Dmitriy Ivanov
00dce52553 Revert "Fix relocation to look for symbols in local group"
This reverts commit fd2747bb58.

Bug: 18222321
Bug: 18211780
Change-Id: I2d4ebab1e73b7277161af76b99f8249825b22d65
2014-11-03 22:15:20 -08:00
Dmitriy Ivanov
eae0977255 Revert "Remove unnecessary lookups during relocations"
This reverts commit 6442dbd3bc.

Bug: 18222321
Bug: 18211780
Change-Id: I87b18a32238a1f75afe56149221b6691f50d9f56
2014-11-03 22:15:17 -08:00
Dmitriy Ivanov
4402804c35 Revert "Fix mips build"
This reverts commit bf3d5ef5fd.

Bug: 18222321
Bug: 18211780
Change-Id: I902ed888197b358c77303f1acb6d5ffd7ae6dcd3
2014-11-03 22:15:13 -08:00
Dmitriy Ivanov
f947be2889 Revert "Fix symbol lookup order during relocation"
This reverts commit 976402cca1.

Bug: 18222321
Bug: 18211780
Change-Id: Iafdd3d843db7b1cf288be9a0232022816622c944
2014-11-03 22:15:08 -08:00
Dmitriy Ivanov
494bee796a Revert "Fix arm64 and arm builds."
This reverts commit 445111a1c9.

Bug: 18222321
Bug: 18211780
Change-Id: I4fa9e1b63ec9b528f8bfed73c2ec15046c43a2fe
2014-11-03 22:14:19 -08:00
Elliott Hughes
d18f4b2578 Ensure we initialize stdin/stdout/stderr's recursive mutexes.
(cherry-pick of 6a03abcfd23f31d1df06eb0059830e22621282bb.)

Bug: 18208568
Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
2014-11-03 13:46:41 -08:00
The Android Automerger
99e148e30c merge in lmp-mr1-release history after reset to 445111a1c9 2014-11-03 06:09:01 -08:00
The Android Automerger
b0daba3da1 merge in lmp-mr1-release history after reset to 445111a1c9 2014-11-02 06:08:55 -08:00
The Android Automerger
13baf92d93 merge in lmp-mr1-release history after reset to 653263a964 2014-11-01 06:09:02 -07:00
Dmitriy Ivanov
445111a1c9 Fix arm64 and arm builds.
Bug: 18186310

(cherry picked from commit 4e446b19d8)

Change-Id: Ibc77a9ade36dc6b9bf5a316b5ab9ae5f0a70e826
2014-10-31 19:29:04 -07:00
Dmitriy Ivanov
976402cca1 Fix symbol lookup order during relocation
Relocate symbol against DF_1_GLOBAL shared libraries
  loaded before this shared library. This includes
  main executable, ld_preloads and other libraries
  that have DF_1_GLOBAL flag set.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit d225a5e652)

Change-Id: I4e889cdf2dfbf8230b0790053d311ee6b0d0ee2d
2014-10-31 17:10:30 -07:00
Dmitriy Ivanov
bf3d5ef5fd Fix mips build
Bug: 18186310

(cherry picked from commit 90b74fb867)

Change-Id: I8d4ed254e5c421b65b62c401abdb1ee07e5dc3b2
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
6442dbd3bc Remove unnecessary lookups during relocations
local_group includes this library and its dependencies.

Bug: 18186310

(cherry picked from commit e47b3f8456)

Change-Id: I93c2d873e924df7319569307444bf603d7d27bf0
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
fd2747bb58 Fix relocation to look for symbols in local group
The local group is a sequence of libraries in default (breadth-first)
  order. It allows RTLD_LOCALLY loaded library to correctly relocate
  symbols within its group (see test-cases).

  Local group lookup is performed after main executable and ld_preloads.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit cfa97f172d)

Change-Id: I5fa8c673f929e4652c738912c7ae078d7ec286d2
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
4d0c1f673f Correct way to specify additional dependencies
Previous one was not covering all the targets

Bug: 17548097
Bug: 18186310

(cherry picked from commit 4a9e1937c5)

Change-Id: I2cd9e58893555d16cbfe291b2d1279621489d5ad
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
382e06ce8e Add dlfcn_test to glibc test suite.
Bug: 18186310

(cherry picked from commit eb27bbae8f)

Change-Id: I1d608dfa12dbafbdcdb8bc6d818c5872404c19e0
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
e4bc6f026a Ignore DT_BIND_NOW (0x18)
Bug: 18186310
Bug: 17552334

(cherry picked from commit ea6eae182a)

Change-Id: I07d6f6fbb462fea329581d0da02f6d88be1c262f
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
1d3e81a9e7 Resolve "unused DT entry" warnings for x86_64
Bug: 18186310

(cherry picked from commit 513e29e16f)

Change-Id: I1e4c5af2cdc09dc978c7a78fcdcf8796c919751e
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
c87f65d2cd Add RTLD_NODELETE flag support
Bug: 18186310
Bug: https://code.google.com/p/android/issues/detail?id=64069

(cherry picked from commit 1b20dafdbe)

Change-Id: Ic02eec22a7c322ece65eb40730a3404f611526b1
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
210ff1b27b Fix mips build
Bug: 18186310

(cherry picked from commit ecf532fa1c)

Change-Id: Ia12f2fa28c8cd3204eb7d6b4c7d872f4e81fb8ef
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
0f47d9c1ce Fix unused DT entry warnings.
DT_STRSZ Implement strtab boundary checks
 DT_FLAGS_1 Warn if flags other than DF_1_NOW|DF_1_GLOBAL are set

Bug: 17552334
Bug: 18186310

(cherry picked from commit 6cdeb5234d)

Change-Id: I7ffc7bc600798308a77ad949a644949b64250ae2
2014-10-31 17:03:59 -07:00
Dmitriy Ivanov
f90e21004e Return has_DT_SYMBOLIC flag.
This reverts commit 8f61d99183

 Despite the fact that static linker does all the work while linking
 -Bsymbolic executables, according to the SCO doc following DT_SYMBOLIC
 and DF_SYMBOLIC flags is still a requirement for the dynamic linker
 as well.

 (see http://www.sco.com/developers/gabi/2012-12-31/ch5.dynamic.html)

Bug: 18186310

(cherry picked from commit 96bc37f2e1)

Change-Id: Ie217be4f3305d877066e4cfe91975ae1c7768330
2014-10-31 17:03:59 -07:00
Elliott Hughes
748fbe5c41 Fix a couple more cases of missing CLOEXEC.
The debuggerd case can probably never happen, because you're crashing at this
point anyway. The system property one seems possible though.

Bug: 18186310

(cherry picked from commit 0dc39f9952)

Change-Id: I3e84488fc246f6c28cbd82e96d0cd4343a12c28a
2014-10-31 17:03:21 -07:00
Dmitriy Ivanov
d5eb10875a Temporary disable DL_WARNs for unused DT_*
Bug: 17552334
Bug: 18186310

(cherry picked from commit 1b77423eff)

Change-Id: I8a9d05195a862bc287fff7156913606f0311b8bb
2014-10-31 17:02:14 -07:00
Dmitriy Ivanov
09608848ed Fix 64bit build
Bug: 18186310

(cherry picked from commit f240aa8089)

Change-Id: Id46f1f9be90a17a58fb44d3540095c8c685c9726
2014-10-31 17:02:14 -07:00
Dmitriy Ivanov
634a045c5c Fix some unused DT_ warnings
* DT_PLTGOT - ignored for non-mips
 * DT_RELCOUNT/RELACOUNT - ignored
 * DT_RELENT/RELAENT - sanity checks
 * DT_SYMENT - sanity check
 * DT_SONAME - ignore for now.

Bug: 18186310

(cherry picked from commit 4a6e9a835a)

Change-Id: Ib40095f0770d65628fc7abac5a471378de35ebe7
2014-10-31 17:02:14 -07:00
Dmitriy Ivanov
b364d95380 Remove has_DT_SYMBOLIC flag
From the elf-spec: "Symbolically bound shared objects are
  identified by the .dynamic entry DT_SYMBOLIC. This tag is
  informational only; the runtime linker processes symbol
  lookups from these objects in the same manner as any
  other object."

Bug: 18186310

(cherry picked from commit 8f61d99183)

Change-Id: I37024799ac8d1837993c8ae78780a448bedd6539
2014-10-31 17:02:13 -07:00
Dmitriy Ivanov
c85e82dde5 Fix dlsym() to take into account RTLD_GLOBAL/LOCAL
Symbols from libraries opened with RTLD_LOCAL (default)
  should not be visible via dlsym(RLTD_DEFAULT/RTLD_NEXT, .)

Bug: 17512583
Bug: 18186310

(cherry picked from commit e8ba50fe0d)

Change-Id: Idf6bbe2233fb2bfc0c88677e7d1fc518fb3f7a8b
2014-10-31 17:02:13 -07:00
Dmitriy Ivanov
926797a8a9 Reformatting
No functional changes.

Bug: 18186310

(cherry picked from commit 6abf624d12)]

Change-Id: I0acf52d8ee7fe2d4f44bc832cbe9fabe1782f03f
2014-10-31 17:02:13 -07:00
Dan Albert
653263a964 Only use <atomic> for C++11 and newer.
Any pre-C++11 clients of stdatomic.h that use libc++ are being forced
over to <atomic>, which they don't have the language support to use.

Bug:17736764

Change-Id: I62445c1f2541410a1569498c09433c7196635537
(cherry picked from commit 3ce0769aa5)
2014-10-30 13:22:34 -07:00
The Android Automerger
09fa97fd17 merge in lmp-mr1-release history after reset to b0693ec582 2014-10-30 06:08:57 -07:00
Elliott Hughes
b0693ec582 Merge changes I0feda6b2,I22d13fde,I49d7d09d,Ice490bfe into lmp-mr1-dev
* changes:
  Fix the type of u_ar0 in <sys/user.h>.
  Add greg_t for arm64.
  POSIX says <signal.h> gets you ucontext_t.
  Add in_port_t and move it and in_addr_t to the correct header file.
2014-10-29 23:22:30 +00:00
Elliott Hughes
0c4e98adbe Fix the type of u_ar0 in <sys/user.h>.
(cherry picked from commit e03950fa0c)

Bug: 18172268
Change-Id: I0feda6b253882f68f47bcf30fad998286cc7f620
2014-10-29 11:57:36 -07:00
Elliott Hughes
d0fb6a2940 Add greg_t for arm64.
This was already present for the other architectures. I think we skipped
this because glibc seems to have an incorrect definition (int rather than
long), but the kernel has the sane definition (just not in a uapi header).

(cherry picked from commit 8e4d371091)

Bug: 18172268
Change-Id: I22d13fdeb6431ea122dd028a229782dcaf2286b2
2014-10-29 11:56:59 -07:00
Elliott Hughes
ab4d5cf242 POSIX says <signal.h> gets you ucontext_t.
POSIX also says that ucontext_t's uc_sigmask has type sigset_t.

MIPS64 strace needs this.

The #define is to keep chromium off our lawn; otherwise it tries to redefine
all this stuff itself. We should probably clean that up and remove the #define.

(cherry picked from commit 26a8eb50a8)

Bug: 18172268
Change-Id: I49d7d09dabfc6c6926a8e1f4b235d041e2f2fc4d
2014-10-29 11:55:02 -07:00
Elliott Hughes
eedbf70e8e Add in_port_t and move it and in_addr_t to the correct header file.
No one's reported this, but I saw it in an Android port of fuser(1).

We still have lots of problems in our network headers because we
get most of the structs direct from the kernel, and it doesn't use
types like this (which is why we've got away without this one for
so long). One day we should probably look at cleaning that up, but
doing so can wait.

(cherry picked from commit 35d226e05d)

Bug: 18172268
Change-Id: Ice490bfe84afb04722d738128053d4c533b8a664
2014-10-29 11:49:45 -07:00
Christopher Ferris
98d57c95bc Add stpcpy assembler version.
For generic, continue to use the C version of the code.

Bug: 13746695

(cherry picked from commit 7d849ac378)

Change-Id: Iae44785f37f9bb59103ab78fb9f74c92f8a95c7f
2014-10-29 11:07:03 -07:00
The Android Automerger
609f5cb21d merge in lmp-mr1-release history after reset to 0cc59dd303 2014-10-29 06:08:51 -07:00
Christopher Ferris
1c8ea807eb Cleanup arm assembly.
Remove the old arm directives.
Change the non-local labels to .L labels.
Add cfi directives to strcpy.S.

Bug: 18157900

(cherry picked from commit c8bd2abab2)

Change-Id: Ifa1c3d16553d142eaa0d744af040f0352538106c
2014-10-28 18:19:33 -07:00
Christopher Ferris
0cc59dd303 Add __memcpy_chk assembly for 64 bit.
Bug: 17623887

(cherry picked from commit 8cf61dab5f)

Change-Id: I91e66ca0c26f04b50308059f9c89d388d55f6e3a
2014-10-28 16:18:47 -07:00
Elliott Hughes
86d16a053e Clean up the architecture-specific makefiles.
Group things appropriately and name each group.

Bug: 18160821

(cherry picked from commit 7c02d9428c)

Change-Id: I863242515af44058154d03e2d8c34678e682d66a
2014-10-28 15:13:36 -07:00
Elliott Hughes
b378c27226 No arm source refers to SOFTFLOAT.
So why bother #defining it?

Bug: 18160821

(cherry picked from commit b1a6c319c4)

Change-Id: I9cd9c144ba7071fddda12fa16d1232ad861b66be
2014-10-28 15:13:04 -07:00
Elliott Hughes
22e2c9d963 Fix mips signed/unsigned signal_test.cpp build breakage.
(cherry picked from commit aa13e839f0)

Bug: 17436734
Change-Id: I167fc5d74c49cca7031c5739bc53fdf3bde71887
2014-10-28 14:02:10 -07:00
Christopher Ferris
43dc3a9aae Remove the unnecessary generic-neon code.
Bug: 18156619
(cherry picked from commit 2169e17482)

Change-Id: I4a7f5bb9ad4c27b274f3a3c86c1617ca0578b98f
2014-10-28 12:07:25 -07:00
Elliott Hughes
1ea31a2901 Merge "Don't mask out SA_RESTORER from sa_flags." into lmp-mr1-dev 2014-10-28 15:36:56 +00:00
Elliott Hughes
cd99bbfd50 Merge "Disable tzdata in $ANDROID_DATA." into lmp-mr1-dev 2014-10-28 15:06:31 +00:00
Elliott Hughes
28ea229bb2 Don't mask out SA_RESTORER from sa_flags.
glibc doesn't do this, and we probably shouldn't either.

Bug: 16703540
Bug: 17436734

(cherry picked from commit afe58ad989)

Change-Id: Iada5d0ae814f438cb276f056b2b5e3675f0e3666
2014-10-28 07:55:53 -07:00
The Android Automerger
05c3adbabf merge in lmp-mr1-release history after reset to aa6cd5819c 2014-10-28 06:10:08 -07:00
Pavel Chupin
8eb8c39299 [x86,x86_64] Fix libgcc unwinding through signal
This change provides __restore/__restore_rt on x86 and __restore_rt on
x86_64 with unwinding information to be able to unwind through signal
frame via libgcc provided unwinding interface. See comments inlined for
more details.

Also remove the test that had a dependency on
__attribute__((cleanup(foo_cleanup))). It doesn't provide us with any
better test coverage than we have from the newer tests, and it doesn't
work well across a variety architectures (presumably because no one uses
this attribute in the real world).

Tested this on host via bionic-unit-tests-run-on-host on both x86 and
x86-64.

Bug: 17436734
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>

(cherry picked from commit 50321e2e66)

Change-Id: Iba90e36958b00c7cc7db5eeebf888dc89ce4d619
2014-10-27 16:42:49 -07:00
Elliott Hughes
190dce9e56 Stack unwinding unit tests.
Bug: 17436734

(cherry picked from commit bee1993a14)

Change-Id: I7205a862ba2c3b474e287f5e9c8982cef4610af9
2014-10-27 16:42:37 -07:00
Elliott Hughes
e5e61a0a92 Use the kernel's sa_restorer for aarch64.
gdb was happy with what we had, but libgcc and libunwind weren't.
libgcc is happy with the kernel's restorer (because of the extra nop),
though libunwind looks like it's going to need code changes regardless.

We could make our restorer more like the kernel's one, but why bother
when we can just let the kernel supply the canonical one?

Bug: 17436734

(cherry picked from commit 1cff9a8964)

Change-Id: Ie13d73fd97395e1979a67c2294e036a97c50000d
2014-10-27 16:42:19 -07:00
Elliott Hughes
5054e1a121 Fix 32-bit arm unwinding through signal frames.
gdb was already okay; libgcc and libunwind need a little extra help.

Bug: 17436734

(cherry picked from commit 148dff3ec6)

Change-Id: I2cc997017acc57c930284af5264f353656b98c7b
2014-10-27 16:41:56 -07:00
Elliott Hughes
7dc2b7b30d Fix signal trampolines.
* LP32 should use sa_restorer too. gdb expects this, and future (>= 3.15) x86
  kernels will apparently stop supporting the case where SA_RESTORER isn't
  set.

* gdb and libunwind care about the exact instruction sequences, so we need to
  modify the code slightly in a few cases to match what they're looking for.

* gdb also cares about the exact function names (for some architectures),
  so we need to use __restore and __restore_rt rather than __sigreturn and
  __rt_sigreturn.

* It's possible that we don't have a VDSO; dl_iterate_phdr shouldn't assume
  that getauxval(AT_SYSINFO_EHDR) will return a non-null pointer.

This fixes unwinding through a signal handler in gdb for all architectures.
It doesn't fix libunwind for arm and arm64. I'll keep investigating that...

(cherry picked from commit 36f451a6d9)

Bug: 17436734
Change-Id: Ic1ea1184db6655c5d96180dc07bcc09628e647cb
2014-10-27 16:41:28 -07:00
Elliott Hughes
4c30130a21 Disable tzdata in $ANDROID_DATA.
Bug: 18139284
Change-Id: I2670dc1791d635139a5d39a438dc08777439476b
2014-10-27 13:38:21 -07:00
The Android Automerger
b50945d935 merge in lmp-mr1-release history after reset to aa6cd5819c 2014-10-27 06:08:44 -07:00
The Android Automerger
fa29966094 merge in lmp-mr1-release history after reset to aa6cd5819c 2014-10-26 06:08:41 -07:00
The Android Automerger
5c9ba49803 merge in lmp-mr1-release history after reset to aa6cd5819c 2014-10-25 06:08:59 -07:00
Elliott Hughes
aa6cd5819c Use mxcr_mask instead of mxcsr_mask to match glibc.
Bug: 18097559

(cherry picked from commit f485547b92)

Change-Id: I242105faa8210abc9635a951b25b127cd64ed23c
2014-10-24 08:43:34 -07:00
The Android Automerger
0e5f7b9b3c merge in lmp-mr1-release history after reset to 8fab8119dd 2014-10-23 06:09:33 -07:00
Elliott Hughes
8fab8119dd Update bionic to tzdata2014i.
From the release notes:

   Changes affecting future time stamps

     Pacific/Fiji will observe DST from 2014-11-02 02:00 to
     2015-01-18 03:00.  (Thanks to Ken Rylander for the heads-up.)
     Guess that future years will use a similar pattern.

     A new Zone Pacific/Bougainville, for the part of Papua New
     Guinea that plans to switch from UTC+10 to UTC+11 on
     2014-12-28 at 02:00.  (Thanks to Kiley Walbom for the
     heads-up.)

   Changes affecting time zone abbreviations

     Since Belarus is not changing its clocks even though Moscow
     is, the time zone abbreviation in Europe/Minsk is changing
     from FET to its more-traditional value MSK on 2014-10-26 at
     01:00.  (Thanks to Alexander Bokovoy for the heads-up about
     Belarus.)

     The new abbreviation IDT stands for the pre-1976 use of UT+8
     in Indochina, to distinguish it better from ICT (UT+7).

   Changes affecting past time stamps

     Many time stamps have been corrected for Asia/Ho_Chi_Minh
     before 1976 (thanks to Trần Ngọc Quân for an indirect pointer
     to Trần Tiến Bình's authoritative book).  Asia/Ho_Chi_Minh has
     been added to zone1970.tab, to give tzselect users in Vietnam
     two choices, since north and south Vietnam disagreed after our
     1970 cutoff.

     Asia/Phnom_Penh and Asia/Vientiane have been turned into
     links, as they differed from existing zones only for older
     time stamps.  As usual, these changes affect pre-1970 time
     stamps only.  Their old contents have been moved to the
     'backzone' file.

Bug: 18085936

(cherry picked from commit a05c2a2a70)

Change-Id: If0253cc1515e1bc98e99c6e24eec797836ca7c27
2014-10-22 13:45:25 -07:00
Christopher Ferris
82eeec689f Merge "Fix generic __memcpy_chk implementation." into lmp-mr1-dev 2014-10-22 20:16:18 +00:00
Christopher Ferris
9b7b0d82eb Merge "Fix race condition in timer disarm/delete." into lmp-mr1-dev 2014-10-22 19:43:44 +00:00
Christopher Ferris
f13e1eb92f Fix generic __memcpy_chk implementation.
- Clean up the labels (add .L to make them local).
- Change to using cfi directives.
- Fix unwinding of the __memcpy_chk fail path.

Bug: 18033671

(cherry pick from commit 7123d4371a)

Change-Id: Ife93bcbfc1949ef29fc8e2dc515b7120632b82b1
2014-10-22 12:02:13 -07:00
Dmitriy Ivanov
702ab5b37e Rename library_offset to library_fd_offset
replace lseek() and use pread() instead
 add test for library_fd_offset > file_size case

Bug: 17762003

(cherry picked from commit a6c1279098)

Change-Id: Ie117c745081ee33d07db5341115ff6c8e98b0dec
2014-10-22 16:35:04 +00:00
The Android Automerger
ddedd3a38d merge in lmp-mr1-release history after reset to c712ceeec4 2014-10-22 06:08:46 -07:00
Ying Wang
3c5c720b0b Build dlext_testzip as custom module.
Use $(BUILD_SYSTEM)/base_rules to build it as custom module, so that
it's exposed to utilities like mm/mmma etc.

Bug: 17887283
Bug: 17762003

(cherry picked from commit 667853d477)

Change-Id: I405797d16f20dc09e5d84b93b6727b634db2fc2c
2014-10-22 08:30:43 +00:00
Christopher Ferris
0724132c32 Fix race condition in timer disarm/delete.
When setting a repeat timer using the SIGEV_THREAD mechanism, it's possible
that the callback can be called after the timer is disarmed or deleted.
This happens because the kernel can generate signals that the timer thread
will continue to handle even after the timer is supposed to be off.

Add two new tests to verify that disarming/deleting doesn't continue to
call the callback.

Modify the repeat test to finish more quickly than before.

Refactor the Counter implementation a bit.

Bug: 18039727
Change-Id: I73192c915cdacf608521b1792c54e5af14a34907
2014-10-21 18:31:02 -07:00
Dmitriy Ivanov
de01780f46 Add file_offset parameter to android_extinfo
Bug: 17762003

(cherry picked from commit 07e5bc152d)

Change-Id: I72d527831384ff5dde013a4c8dfe639fbec165f5
2014-10-21 13:52:49 -07:00
The Android Automerger
75f6f21a75 merge in lmp-mr1-release history after reset to c712ceeec4 2014-10-21 06:08:46 -07:00
Hans Boehm
c712ceeec4 Make memory_order_acquire visible in global namespace
We were missing that using directive when including <atomic>.

Bug:17736764
Change-Id: Ie8ca92a952749415567bcd5fa21d56629a364660
(cherry picked from commit 76ac4d0853)
2014-10-20 11:41:34 -07:00
The Android Automerger
0f17126b24 merge in lmp-mr1-release history after reset to 59a02860a4 2014-10-20 06:08:44 -07:00
The Android Automerger
eca44bc1f3 merge in lmp-mr1-release history after reset to 59a02860a4 2014-10-19 06:08:38 -07:00
The Android Automerger
99415296ac merge in lmp-mr1-release history after reset to 59a02860a4 2014-10-18 06:09:03 -07:00
The Android Automerger
f020640c09 merge in lmp-mr1-release history after reset to 59a02860a4 2014-10-16 06:09:16 -07:00
The Android Automerger
466c8cbd50 merge in lmp-mr1-release history after reset to 59a02860a4 2014-10-15 06:09:02 -07:00
The Android Automerger
c9b1201be1 merge in lmp-mr1-release history after reset to 59a02860a4 2014-10-14 06:08:58 -07:00
Christopher Ferris
59a02860a4 Merge "Return total footprint, not high water mark." into lmp-mr1-dev 2014-10-13 19:36:56 +00:00
Christopher Ferris
f4ada9c9ce Return total footprint, not high water mark.
The mallinfo usmblks value returned by dlmalloc is a little misleading.
It's not the current max, it's the historical high water mark. This
leads to dumpsys meminfo producing native memory numbers that don't add up.
Change this to the real total footprint, not this high water mark.

Bug: 17265653
Change-Id: Id0293a1b50c9b0be8795405049f537a51ab0e8b7
2014-10-13 12:29:30 -07:00
The Android Automerger
91221be747 merge in lmp-mr1-release history after reset to e0fafb019e 2014-10-13 06:09:12 -07:00
The Android Automerger
d60cda85b9 merge in lmp-mr1-release history after reset to 2f25cf373c 2014-10-12 06:08:41 -07:00
The Android Automerger
50d615236d merge in lmp-mr1-release history after reset to 2f25cf373c 2014-10-11 06:08:51 -07:00
Christopher Ferris
e0fafb019e am c891e240: Add back symbols to fix Greed for Glory franchise.
* commit 'c891e24073830e07ba7373dee554ff2c70e1d313':
  Add back symbols to fix Greed for Glory franchise.
2014-10-10 20:47:00 +00:00
Elliott Hughes
2f25cf373c Fix pthread_attr_getstack under valgrind.
valgrind seems to mess with the stack enough that the kernel will
report "[stack:pid]" rather than "[stack]" in /proc/self/maps, so
switch to the task-specific file instead to force "[stack]". (There
are two conditions in the kernel code that decides which form to
output.)

Bug: 17897476

(cherry picked from commit 9afb2f2106)

Change-Id: I92c331ef6fb5868af49e75bc595710d290a95f5b
2014-10-10 10:57:48 -07:00
Christopher Ferris
7f4618cbc8 am c9734d24: Re-add dlmalloc for 32 bit.
* commit 'c9734d24d92f4737f5ab3808c77d816a1b084582':
  Re-add dlmalloc for 32 bit.
2014-10-09 22:02:00 +00:00
The Android Automerger
d67e1d8ae9 merge in lmp-mr1-release history after reset to e5d4fc39e3 2014-10-09 06:08:53 -07:00
The Android Automerger
bc9cee7f58 merge in lmp-mr1-release history after reset to e5d4fc39e3 2014-10-08 06:09:28 -07:00
Elliott Hughes
e5d4fc39e3 am 1543fdf6: Work around a bug in Immersion\'s libImmEmulatorJ.so.
* commit '1543fdf616ddebee7819214437527f380e5c743b':
  Work around a bug in Immersion's libImmEmulatorJ.so.
2014-10-08 05:24:46 +00:00
Dan Albert
55ee845b8e Inline helpers need to be exported unmangled.
__open_2() is used by the fortify implementation of open(2) in
fcntl.h, and as such needs an unmangled C name. For some reason
(inlining?), this doesn't cause problems at the default optimization
level, but does for -O0.

The rest of these didn't cause build failures, but they look suspect
and probably will, we just haven't caught them yet.

(cherry-pick of 658727e111 with conflicts
in stdio.h and string.h.)

Bug: 17784968
Change-Id: I7391a7a8999ee204eaf6abd14a3d5373ea419d5b
2014-10-07 18:51:24 -07:00
Nick Kralevich
ce92b41a00 cdefs.h: add artificial attribute to FORTIFY_SOURCE functions
Otherwise the gcc compiler warning doesn't show up.

Add -Wno-error to fortify related tests. Fortify related tests
are expected to be examples of bad programs, and in many
cases shouldn't compile cleanly. Rewriting them to compile
cleanly isn't feasible nor desirable.

Bug: 17784968

(cherry picked from commit 1aaa17802c)

Change-Id: Ib6df1a3f44b55b1fff222e78395c10c51cd39817
2014-10-07 16:37:04 -07:00
Elliott Hughes
b5e7eba6d1 Work around a bug in Immersion's libImmEmulatorJ.so.
This library calls pthread_mutex_lock and pthread_mutex_unlock with a NULL
pthread_mutex_t*. This gives them (and their users) one release to fix things.

Bug: 17443936

(cherry picked from commit 7d3f553f98)

Change-Id: Ie26bbecd3a74d61113b51c18832872499b97ee86
2014-10-07 16:08:46 -07:00
Elliott Hughes
ea8dea8cb7 Merge "Improve <sys/cdefs.h>." into lmp-mr1-dev 2014-10-07 18:51:36 +00:00
Elliott Hughes
d87d401ab1 Improve <sys/cdefs.h>.
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.

Lose a bunch of macros that weren't being used.

Lose three dead files from the DNS code.

Bug: 17784968

(cherry picked from commit 2cfb4e8e2e)

Change-Id: I5e96146f92c0521248c78c0933bec5e9a9818222
2014-10-07 11:40:09 -07:00
Christopher Ferris
4aace3852d am 2cf15571: am 40bc7cd4: (-s ours) DO NOT MERGE Re-add .save directive for arm assembler code.
* commit '2cf155713aaba451065d593335d544f2ada24ddf':
  DO NOT MERGE  Re-add .save directive for arm assembler code.
2014-10-07 17:42:39 +00:00
The Android Automerger
f51bbbe319 merge in lmp-mr1-release history after reset to 6c4e16f634 2014-10-07 06:08:55 -07:00
Elliott Hughes
6c4e16f634 Merge "further cleanup memcpy fortify implementation" into lmp-mr1-dev 2014-10-07 00:30:34 +00:00
Christopher Ferris
27355affc1 am d11eac34: Force export symbols on all x86 variants in libc.
* commit 'd11eac3455a059a092ceee92eda9905e1d661e94':
  Force export symbols on all x86 variants in libc.
2014-10-07 00:20:10 +00:00
Nick Kralevich
db408bf421 further cleanup memcpy fortify implementation
Bug: 17784968

(cherry picked from commit b84f667e93)

Change-Id: I68fc2cc0a1ee7f0887edf3681eb83ef678de1383
2014-10-06 16:18:32 -07:00
Nick Kralevich
7ad2147a08 string.h: remove unused variable
(cherry picked from commit 48be71d02b)

Bug: 17784968
Change-Id: Iac7732fb4f7fe42977cb9f62472bb636e17e5232
2014-10-06 10:17:01 -07:00
The Android Automerger
26df9bf109 merge in lmp-mr1-release history after reset to 02542b3bbd 2014-10-06 06:08:57 -07:00
The Android Automerger
4877fe15c2 merge in lmp-mr1-release history after reset to 02542b3bbd 2014-10-05 06:08:48 -07:00
Alex Van Brunt
02542b3bbd am a5087148: Reimplement clock(3) using clock_gettime(3)
* commit 'a508714800242b294291060641ed35d719bdc857':
  Reimplement clock(3) using clock_gettime(3)
2014-10-04 16:44:11 +00:00
The Android Automerger
975164af3c merge in lmp-mr1-release history after reset to 22f5a61d95 2014-10-04 06:09:07 -07:00
Elliott Hughes
22f5a61d95 am ea9800e9: Explain why clock(3) isn\'t broken.
* commit 'ea9800e98598c71fe76c4e2a0d0498b6bd490a83':
  Explain why clock(3) isn't broken.
2014-10-04 00:06:27 +00:00
Ningsheng Jian
04f5f4100c Fix gdb could not get shared library list issue
Get dynamic flags from phdr table's correct entry rather the first
entry, so that the following DT_DEBUG entry can be set.

Also fix the undefined reference to LoadTask::deleter issue under gcc
-O0 option.

Bug: 17524778

(cherry picked from commit e93be99da0)

Change-Id: I347792dab25c7b19c3fc690e03d20899ce1e26e0
2014-10-02 15:35:47 -07:00
The Android Automerger
1f5a9a4b35 merge in lmp-mr1-release history after reset to e4f8962ab5 2014-10-02 06:09:27 -07:00
Dmitriy Ivanov
1cd0c6777f L-MR1 specific fixes
Reset soinfo version to 0.
 Disable ifunc test for arm64 because of old toolchain
 in lmp-mr1-dev branch

 Note: this commit should be reverted in -plus-aosp branch.

Change-Id: I2d6d996d43bc35d5d4975c745779f43a988b31e6
2014-10-01 16:26:49 -07:00
Dmitriy Ivanov
7d971ec14b Fix unload of recursively linked library
Expanded test for recursive libs. Fixed bug with unnecessary
  soinfo_free of already loaded library.

(cherry picked from commit a6ac54a215)

Change-Id: I6907c723d9fbdf6b2777f3f236b1e29b0843edd6
2014-10-01 16:04:58 -07:00
Dmitriy Ivanov
f4cb631364 Add IFUNC support for arm64 and IRELATIVE reloc
There are number of changes in the way IFUNC related relocations are done:
 1. IRELATIVE relocations are now supported for x86/x86_64 and arm64.
 2. IFUNC relocations are now relying on static linker to generate
    them in correct order - this removes necessety of additional
    relocation pass for ifuncs.
 3. Related to 2: rela?.dyn relocations are preformed before .plt ones.
 4. Ifunc are resolved on symbol lookup this approach allowed to avoid
    mprotect(PROT_WRITE) call on r-x program segments.

Bug: 17399706
Bug: 17177284

(cherry picked from commit 9aea164457)

Change-Id: Ie19d900fc203beb93faf8943b0d06d534a6de4ad
2014-10-01 16:04:31 -07:00
Dmitriy Ivanov
ef1306d777 Refactoring: C++11 style DISABLE_ bionic marcos
Enable the -std=gnu++11 flag for libstdc++ static and
  dynamic libs.

  ScopeGuard uses DISABLE_ macros instead of '= delete';

(cherry picked from commit d9ff722661)

Change-Id: If2573d080770e18b36b56106f2369f7bb682cd3c
2014-10-01 16:03:51 -07:00
Dmitriy Ivanov
61c4147fa8 Reset enviroment for math_tests
Bug: 17390824

(cherry picked from commit 7b956ede3f)

Change-Id: I5d804ceb5e69533584161bfed6787529cd8296fb
2014-10-01 16:03:40 -07:00
Dmitriy Ivanov
ae69a9584b Load libraries in breadth-first order
This patch fixes the problem with symbol search order
  for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
  and ld_preloads in correct order.

Bug: https://code.google.com/p/android/issues/detail?id=74255
Attempt: 2

(cherry picked from commit 14669a939d)

Change-Id: Id87540c96a2242220967b6fa5d84ddcd829e2b97
2014-10-01 16:01:28 -07:00
Dmitriy Ivanov
c0133a73b6 Revert "Load libraries in breadth-first order"
This reverts commit a3ad450a2e.

(cherry picked from commit 498eb18b82)

Change-Id: Iec7eab83d0c0ed1604e1e8ea3f9e9d0ce1d29680
2014-10-01 16:00:52 -07:00
Dmitriy Ivanov
8de1ddece0 Fix order of soinfo links (repairs libcxx tests).
(cherry picked from commit b2a30ee8d2)

Change-Id: I59c5333bc050cbbea14051cea9220be2f64ee383
2014-10-01 16:00:41 -07:00
Dmitriy Ivanov
59c12a6527 Load libraries in breadth-first order
This patch fixes the problem with symbol search order
  for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
  and ld_preloads in correct order.

Bug: https://code.google.com/p/android/issues/detail?id=74255

(cherry picked from commit a3ad450a2e)

Change-Id: I1125de10272c84e4f075cbc72859c1f6b3e89943
2014-10-01 16:00:29 -07:00
Chih-Hung Hsieh
81fe2b16dc Enable clang compilation with libc but not linker.
Clang is still disabled for x86 and x86_64 long double code,
for x86_64 special assembly instruction, and the linker module.

BUG: 17163651
BUG: 17302991
BUG: 17403674

(cherry picked from commit b58db8b083)

Change-Id: I916c05056d37a9c287b0a5ae3b1a209d98c8f70e
2014-10-01 15:57:09 -07:00
Dmitriy Ivanov
7210c41fdc Encapsulate soinfo_link_image and soinfo_relocate
Also get rid of needed[] array for these functions

(cherry picked from commit 29bbc9dd4c)

Change-Id: Id208621f66afa2e02a6b3facacee7d874466d81b
2014-10-01 15:56:44 -07:00
Dmitriy Ivanov
4466bd72fb Implement LinkedList::visit()
(cherry picked from commit a492605849)

Change-Id: I59554be45c910bfe33494016595a5ade9daad230
2014-10-01 15:56:23 -07:00
Dmitriy Ivanov
ff01f6fcce Introduce size-based r/w allocators
(cherry picked from commit 0cd83ebb0e)

Change-Id: Ib037bd5313c9a78b6051482f14e789aa820b4dd1
2014-10-01 15:55:58 -07:00
Dmitriy Ivanov
4d01d08c29 Erase elements in LinkedList::remove_if
(cherry picked from commit 4bea498544)

Change-Id: I1ffe248bc2b7572f38fbd987e9c6db5ecbd4559d
2014-10-01 15:55:35 -07:00
Dmitriy Ivanov
cfad7ae934 Replace NULL with nullptr
(cherry picked from commit 851135bf99)

Change-Id: Ic4997907680db7472ef38ffb0f0ca66fff37b797
2014-10-01 15:54:26 -07:00
Dmitriy Ivanov
5dfe802d0d Remove unnecessary calls to LinkedList::clear()
(cherry picked from commit 608217e167)

Change-Id: I031359d79b2e77977ace197ef410e41539dc0ce6
2014-10-01 15:53:07 -07:00
Dmitriy Ivanov
93c3f4203c Enable __cxa_atexit && __cxa_finalize for linker
This allows adding destructors to classes used
 for global variables.

(cherry picked from commit 14241402de)

Change-Id: I1d8776130d1e01a8c53d23a2949f5010f4c96b16
2014-10-01 15:52:38 -07:00
Dmitriy Ivanov
3bbd218ef1 Bump soinfo version
This includes:
 1. Placing has_ifunc after fields with version = 0
 2. Switch to has_min_version(v) function.
 3. Minor soinfo initialization refactoring (placement new + ctor)

(cherry picked from commit 0d15094287)

Change-Id: Idf135fdd3d4826b5653f32add2adc6db5d4a4f95
2014-10-01 15:52:15 -07:00
Dmitriy Ivanov
bd321c1106 Run constructors before resolving ifunc functions
Bug: 17177284

(cherry picked from commit 9598b8c415)

Change-Id: I2c9631ee1cd77f8cf95ec0216a35b605c8786454
2014-10-01 15:51:47 -07:00
Brigid Smith
31b88da843 Added test for ifunc support in dynamic linker.
ifuncs now work in i386 and x86_64 when called in the same library as
well as in a different library.

Bug:6657325
(cherry picked from commit c5a13efa9b)

Change-Id: I321d780bc2f9bd1baa749e1acacd2683aefe827b
2014-10-01 15:50:38 -07:00
Elliott Hughes
e4f8962ab5 Merge "Update bionic to tzdata 2014h." into lmp-mr1-dev 2014-10-01 18:02:51 +00:00
Elliott Hughes
d18205049d Update bionic to tzdata 2014h.
From the release notes:

  Changes affecting past time stamps

    America/Jamaica's 1974 spring-forward transition was Jan. 6, not Apr. 28.

    Shanks says Asia/Novokuznetsk switched from LMT (not "NMT") on 1924-05-01,
    not 1920-01-06.  The old entry was based on a misinterpretation of Shanks.

    Some more zones have been turned into links, when they differed
    from existing zones only for older time stamps.  As usual,
    these changes affect UTC offsets in pre-1970 time stamps only.
    Their old contents have been moved to the 'backzone' file.
    The affected zones are: Africa/Blantyre, Africa/Bujumbura,
    Africa/Gaborone, Africa/Harare, Africa/Kigali, Africa/Lubumbashi,
    Africa/Lusaka, Africa/Maseru, and Africa/Mbabane.

Bug: 17731498

(cherry picked from commit 0c8fb51e6b)

Change-Id: Icf8a9cbd309951b4ffc20c74eb1e78c1e39c222f
2014-10-01 10:21:07 -07:00
Elliott Hughes
b5f5b0e418 Fix update-tzdata.py to rebuild icu4c .dat file.
Bug: 17731498

(cherry picked from commit f8896c6c93)

Change-Id: If97e1ccf593a2ed6c2356077e660d6fd88a05875
2014-10-01 10:07:24 -07:00
The Android Automerger
dd4b377612 merge in lmp-mr1-release history after reset to aaad548535 2014-10-01 06:09:15 -07:00
The Android Automerger
f9c31b1115 merge in lmp-mr1-release history after reset to aaad548535 2014-09-30 06:09:53 -07:00
The Android Automerger
e09a9d77d2 merge in lmp-mr1-release history after reset to aaad548535 2014-09-29 06:09:50 -07:00
The Android Automerger
bc04ede139 merge in lmp-mr1-release history after reset to aaad548535 2014-09-28 06:08:54 -07:00
The Android Automerger
fe054482cc merge in lmp-mr1-release history after reset to aaad548535 2014-09-27 06:09:13 -07:00
The Android Automerger
a950f53fc3 merge in lmp-mr1-release history after reset to 086bb382db 2014-09-25 06:09:36 -07:00
The Android Automerger
e647a62805 merge in lmp-mr1-release history after reset to 027d2717d0 2014-09-24 06:09:48 -07:00
The Android Automerger
bc2fb531b7 merge in lmp-mr1-release history after reset to 027d2717d0 2014-09-23 15:13:51 -07:00
The Android Automerger
460c53d4d4 merge in lmp-mr1-release history after reset to 027d2717d0 2014-09-23 04:45:29 -07:00
The Android Automerger
8f0c298a3d merge in lmp-mr1-release history after reset to 027d2717d0 2014-09-22 11:44:31 -07:00
The Android Automerger
d830465de8 merge in lmp-mr1-release history after reset to 027d2717d0 2014-09-22 11:13:42 -07:00
The Android Automerger
306d80e339 merge in lmp-mr1-release history after reset to 027d2717d0 2014-09-22 10:17:00 -07:00
The Android Automerger
6078d68321 merge in lmp-release history after reset to 027d2717d0 2014-09-15 06:09:45 -07:00
The Android Automerger
277c1b00f5 merge in lmp-release history after reset to 7e00b44e80 2014-09-14 06:09:35 -07:00
The Android Automerger
50982fd0c4 merge in lmp-release history after reset to 1d12f186ed 2014-09-13 08:42:01 -07:00
The Android Automerger
25232c43fc merge in lmp-release history after reset to 7e00b44e80 2014-09-13 06:09:46 -07:00
The Android Automerger
1d12f186ed merge in lmp-release history after reset to 33a73bfa07 2014-09-11 06:09:09 -07:00
The Android Automerger
fab4d76b46 merge in lmp-release history after reset to 7efad83d43 2014-09-10 06:09:15 -07:00
The Android Automerger
604b2f5789 merge in lmp-release history after reset to 7efad83d43 2014-09-09 06:09:23 -07:00
The Android Automerger
ddca20bda4 merge in lmp-release history after reset to 47ed03f70c 2014-09-08 06:09:42 -07:00
The Android Automerger
d0beefdcd3 merge in lmp-release history after reset to 47ed03f70c 2014-09-07 06:08:57 -07:00
The Android Automerger
ee809b90e8 merge in lmp-release history after reset to dc3814bcf9 2014-09-06 08:50:41 -07:00
The Android Automerger
b2c6088b1e merge in lmp-release history after reset to 5beddb7d64 2014-09-06 06:08:46 -07:00
The Android Automerger
dc3814bcf9 merge in lmp-release history after reset to 1e010d6039 2014-09-04 06:09:31 -07:00
The Android Automerger
d9bead2357 merge in lmp-release history after reset to cb093d1f55 2014-09-03 06:09:05 -07:00
The Android Automerger
8c673ec8e9 merge in lmp-release history after reset to c191a8adee 2014-09-02 06:09:09 -07:00
The Android Automerger
daebe2764b merge in lmp-release history after reset to b2eb09a9ed 2014-09-01 07:54:46 -07:00
The Android Automerger
2fcb94d52c merge in lmp-release history after reset to b2eb09a9ed 2014-08-31 09:30:23 -07:00
Christopher Ferris
20dc3f8fa4 Replace snprintf calls in linker.
When enabling debug malloc, the snprintf calls in the linker fails to
update the buffer.

The problem is that snprintf makes a call to pthread_getspecific that
returns a valid pointer, but the data it points to is zero. This should
never happen and causes the snprintf to stop and do nothing.

Temporarily replace snprintf with a different implementation to work
around this issue.

Bug: 16874447
Bug: 17302493
Change-Id: I7a500f28adf153150cf2812fae745ff41f1c48d3
2014-08-27 16:12:09 -07:00
The Android Automerger
54a6221cc2 merge in lmp-release history after reset to 3f7635f490 2014-08-27 06:09:31 -07:00
The Android Automerger
489b5d23fd merge in lmp-release history after reset to 84d0683a82 2014-08-26 06:09:09 -07:00
The Android Automerger
5f17e16e92 merge in lmp-release history after reset to 84d0683a82 2014-08-25 06:08:46 -07:00
The Android Automerger
3bd669c605 merge in lmp-release history after reset to 84d0683a82 2014-08-24 06:08:24 -07:00
The Android Automerger
cb278332cb merge in lmp-release history after reset to 84d0683a82 2014-08-23 06:09:07 -07:00
The Android Automerger
fe9787ece9 merge in lmp-release history after reset to 1506fc178e 2014-08-21 06:09:26 -07:00
The Android Automerger
bae5898f3d merge in lmp-release history after reset to 1506fc178e 2014-08-20 06:08:54 -07:00
The Android Automerger
08f6f664ed merge in lmp-release history after reset to 6df7b60998 2014-08-19 06:08:52 -07:00
Christopher Ferris
a0108accb2 Fix leak_realloc, copy entire allocation.
Bug: 16874447
Change-Id: Ie54a73fd75529961195fa5173d9116d0ae897b03
2014-08-18 14:10:28 -07:00
The Android Automerger
58df7d814e merge in lmp-release history after reset to d8e007695c 2014-08-18 06:08:40 -07:00
The Android Automerger
147ce71ddc merge in lmp-release history after reset to d8e007695c 2014-08-17 07:14:34 -07:00
The Android Automerger
2e7c8634b7 merge in lmp-release history after reset to 8a84d383fb 2014-08-14 06:09:40 -07:00
The Android Automerger
25ffdd7b9f merge in lmp-release history after reset to 72d7e667c7 2014-08-13 06:10:07 -07:00
The Android Automerger
e9f34a3ee7 merge in lmp-release history after reset to 72d7e667c7 2014-08-12 06:08:45 -07:00
The Android Automerger
c323d5efb8 merge in lmp-release history after reset to 72d7e667c7 2014-08-11 06:08:39 +00:00
The Android Automerger
6cde02273f merge in lmp-release history after reset to 72d7e667c7 2014-08-10 06:08:22 -07:00
The Android Automerger
e3ff5fca61 merge in lmp-release history after reset to f4d21fba06 2014-08-09 06:08:34 -07:00
Christopher Ferris
b5e0854284 Add a way to disable backtracing in malloc debug.
The property libc.debug.malloc.nobacktrace set to non-zero disables
getting backtracing when using mode 1 or mode 10.

Bug: 16874447

Change-Id: I7650ba9f4385b5110b743cab01e877fc69545b3c
2014-08-08 12:49:19 -07:00
The Android Automerger
6b9b454d55 merge in lmp-release history after reset to 3e7b8e2a8b 2014-08-07 06:08:25 -07:00
The Android Automerger
5984773a8d merge in lmp-release history after reset to db7a17d4ff 2014-08-06 06:08:43 -07:00
The Android Automerger
b4725def2e merge in lmp-release history after reset to 1b1966d944 2014-08-05 06:08:26 -07:00
The Android Automerger
b8d00ef3ba merge in lmp-release history after reset to 61833de613 2014-08-04 06:08:13 -07:00
The Android Automerger
39978ccb7f merge in lmp-release history after reset to 61833de613 2014-08-03 06:08:23 -07:00
The Android Automerger
6447d2f4de merge in lmp-release history after reset to 61833de613 2014-08-02 06:08:40 -07:00
Christopher Ferris
1183762969 Use libunwindbacktrace for debug malloc code.
Create a method of disabling the debug allocation code paths so that
it's possible to use the libunwindbacktrace library without any
modifications.

Use this path to create and destroy the maps for the process. It's not
stricly necessary in the init code since the symbols are not modified
until after the initialize calls.

Also, remove the debug_XXX source files that doesn't need to be in libc.so.

Fix the maps reading code since it was completely broken for 64 bit.

Bug: 16408686

(cherry picked from commit 861c0ef37b)

Change-Id: I04445f0cf9a1e85172b64d57df92eb7939ce2332
2014-07-30 15:58:42 -07:00
The Android Automerger
bdf601894f merge in lmp-release history after reset to 1a5db57d5a 2014-07-29 06:08:34 -07:00
The Android Automerger
6a20f051a2 merge in lmp-release history after reset to c1a6a72560 2014-07-28 09:19:57 -07:00
The Android Automerger
8bc74887c1 merge in lmp-release history after reset to c1a6a72560 2014-07-27 06:08:13 -07:00
The Android Automerger
1b710ff000 merge in lmp-release history after reset to c1a6a72560 2014-07-26 06:08:31 -07:00
The Android Automerger
13fb0584e1 merge in lmp-release history after reset to c86950cb3f 2014-07-24 06:08:27 -07:00
Colin Cross
4514aa630c HACK: remove %m support from printf.
The change that added this support causes a cpu hard lock on one
device.  This code clearly isn't at fault, but disabling it to
unblock until we can find a real fix.

Bug: 16484311
Change-Id: I33834dc49d959ae403b10d2c7cad12ae2950f772
2014-07-23 15:49:17 -07:00
Elliott Hughes
0caf70e98e Fix belated review comments on syslog change.
Bug: 14292866

(cherry picked from commit afe6360627)

Change-Id: I8e3cc6b37b2539e51a27261ffb5d6e58266ce11d
2014-07-23 15:49:09 -07:00
539 changed files with 12352 additions and 22096 deletions

View File

@@ -4,52 +4,40 @@ Working on bionic
What are the big pieces of bionic? What are the big pieces of bionic?
---------------------------------- ----------------------------------
#### libc/ --- libc.so, libc.a libc/ --- libc.so, libc.a
The C library. Stuff like fopen(3) and kill(2).
libm/ --- libm.so, libm.a
The math library. Traditionally Unix systems kept stuff like sin(3) and
cos(3) in a separate library to save space in the days before shared
libraries.
libdl/ --- libdl.so
The dynamic linker interface library. This is actually just a bunch of
stubs that the dynamic linker replaces with pointers to its own
implementation at runtime. This is where stuff like dlopen(3) lives.
libstdc++/ --- libstdc++.so
The C++ ABI support functions. The C++ compiler doesn't know how to
implement thread-safe static initialization and the like, so it just calls
functions that are supplied by the system. Stuff like __cxa_guard_acquire
and __cxa_pure_virtual live here.
The C library. Stuff like `fopen(3)` and `kill(2)`. linker/ --- /system/bin/linker and /system/bin/linker64
The dynamic linker. When you run a dynamically-linked executable, its ELF
file has a DT_INTERP entry that says "use the following program to start me".
On Android, that's either linker or linker64 (depending on whether it's a
32-bit or 64-bit executable). It's responsible for loading the ELF executable
into memory and resolving references to symbols (so that when your code tries
to jump to fopen(3), say, it lands in the right place).
#### libm/ --- libm.so, libm.a tests/ --- unit tests
The tests/ directory contains unit tests. Roughly arranged as one file per
The math library. Traditionally Unix systems kept stuff like `sin(3)` and publicly-exported header file.
`cos(3)` in a separate library to save space in the days before shared benchmarks/ --- benchmarks
libraries. The benchmarks/ directory contains benchmarks.
#### libdl/ --- libdl.so
The dynamic linker interface library. This is actually just a bunch of stubs
that the dynamic linker replaces with pointers to its own implementation at
runtime. This is where stuff like `dlopen(3)` lives.
#### libstdc++/ --- libstdc++.so
The C++ ABI support functions. The C++ compiler doesn't know how to implement
thread-safe static initialization and the like, so it just calls functions that
are supplied by the system. Stuff like `__cxa_guard_acquire` and
`__cxa_pure_virtual` live here.
#### linker/ --- /system/bin/linker and /system/bin/linker64
The dynamic linker. When you run a dynamically-linked executable, its ELF file
has a `DT_INTERP` entry that says "use the following program to start me". On
Android, that's either `linker` or `linker64` (depending on whether it's a
32-bit or 64-bit executable). It's responsible for loading the ELF executable
into memory and resolving references to symbols (so that when your code tries to
jump to `fopen(3)`, say, it lands in the right place).
#### tests/ --- unit tests
The `tests/` directory contains unit tests. Roughly arranged as one file per
publicly-exported header file.
#### benchmarks/ --- benchmarks
The `benchmarks/` directory contains benchmarks.
What's in libc/? What's in libc/?
---------------- ----------------
<pre>
libc/ libc/
arch-arm/ arch-arm/
arch-arm64/ arch-arm64/
@@ -133,7 +121,6 @@ libc/
zoneinfo/ zoneinfo/
# Android-format time zone data. # Android-format time zone data.
# See 'Updating tzdata' later. # See 'Updating tzdata' later.
</pre>
Adding system calls Adding system calls
@@ -173,86 +160,3 @@ This is fully automated:
1. Run update-tzdata.py. 1. Run update-tzdata.py.
Verifying changes
-----------------
If you make a change that is likely to have a wide effect on the tree (such as a
libc header change), you should run `make checkbuild`. A regular `make` will
_not_ build the entire tree; just the minimum number of projects that are
required for the device. Tests, additional developer tools, and various other
modules will not be built. Note that `make checkbuild` will not be complete
either, as `make tests` covers a few additional modules, but generally speaking
`make checkbuild` is enough.
Running the tests
-----------------
The tests are all built from the tests/ directory.
### Device tests
$ mma
$ adb sync
$ adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
$ adb shell \
/data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
# Only for 64-bit targets
$ adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
$ adb shell \
/data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
### Host tests
The host tests require that you have `lunch`ed either an x86 or x86_64 target.
$ mma
# 64-bit tests for 64-bit targets, 32-bit otherwise.
$ mm bionic-unit-tests-run-on-host
# Only exists for 64-bit targets.
$ mm bionic-unit-tests-run-on-host32
### Against glibc
As a way to check that our tests do in fact test the correct behavior (and not
just the behavior we think is correct), it is possible to run the tests against
the host's glibc.
$ mma
$ bionic-unit-tests-glibc32 # already in your path
$ bionic-unit-tests-glibc64
Gathering test coverage
-----------------------
For either host or target coverage, you must first:
* `$ export NATIVE_COVERAGE=true`
* Note that the build system is ignorant to this flag being toggled, i.e. if
you change this flag, you will have to manually rebuild bionic.
* Set `bionic_coverage=true` in `libc/Android.mk` and `libm/Android.mk`.
### Coverage from device tests
$ mma
$ adb sync
$ adb shell \
GCOV_PREFIX=/data/local/tmp/gcov \
GCOV_PREFIX_STRIP=`echo $ANDROID_BUILD_TOP | grep -o / | wc -l` \
/data/nativetest/bionic-unit-tests/bionic-unit-tests32
$ acov
`acov` will pull all coverage information from the device, push it to the right
directories, run `lcov`, and open the coverage report in your browser.
### Coverage from host tests
First, build and run the host tests as usual (see above).
$ croot
$ lcov -c -d $ANDROID_PRODUCT_OUT -o coverage.info
$ genhtml -o covreport coverage.info # or lcov --list coverage.info
The coverage report is now available at `covreport/index.html`.

View File

@@ -32,6 +32,7 @@ benchmark_c_flags = \
benchmark_src_files = \ benchmark_src_files = \
benchmark_main.cpp \ benchmark_main.cpp \
math_benchmark.cpp \ math_benchmark.cpp \
property_benchmark.cpp \
pthread_benchmark.cpp \ pthread_benchmark.cpp \
semaphore_benchmark.cpp \ semaphore_benchmark.cpp \
stdio_benchmark.cpp \ stdio_benchmark.cpp \
@@ -40,8 +41,7 @@ benchmark_src_files = \
unistd_benchmark.cpp \ unistd_benchmark.cpp \
# Build benchmarks for the device (with bionic's .so). Run with: # Build benchmarks for the device (with bionic's .so). Run with:
# adb shell bionic-benchmarks32 # adb shell bionic-benchmarks
# adb shell bionic-benchmarks64
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := bionic-benchmarks LOCAL_MODULE := bionic-benchmarks
LOCAL_MODULE_STEM_32 := bionic-benchmarks32 LOCAL_MODULE_STEM_32 := bionic-benchmarks32
@@ -49,46 +49,32 @@ LOCAL_MODULE_STEM_64 := bionic-benchmarks64
LOCAL_MULTILIB := both LOCAL_MULTILIB := both
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += $(benchmark_c_flags) LOCAL_CFLAGS += $(benchmark_c_flags)
LOCAL_SRC_FILES := $(benchmark_src_files) property_benchmark.cpp LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
LOCAL_CXX_STL := libc++ LOCAL_SHARED_LIBRARIES += libstlport
LOCAL_SRC_FILES := $(benchmark_src_files)
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)
# We don't build a static benchmark executable because it's not usually
# useful. If you're trying to run the current benchmarks on an older
# release, it's (so far at least) always because you want to measure the
# performance of the old release's libc, and a static benchmark isn't
# going to let you do that.
# Build benchmarks for the host (against glibc!). Run with:
include $(CLEAR_VARS)
LOCAL_MODULE := bionic-benchmarks-glibc
LOCAL_MODULE_STEM_32 := bionic-benchmarks-glibc32
LOCAL_MODULE_STEM_64 := bionic-benchmarks-glibc64
LOCAL_MULTILIB := both
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += $(benchmark_c_flags)
LOCAL_LDFLAGS += -lrt
LOCAL_SRC_FILES := $(benchmark_src_files)
LOCAL_CXX_STL := libc++
include $(BUILD_HOST_EXECUTABLE)
ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64)) ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
include $(LOCAL_PATH)/../build/run-on-host.mk ifeq ($(TARGET_ARCH),x86)
LINKER = linker
NATIVE_SUFFIX=32
else
LINKER = linker64
NATIVE_SUFFIX=64
endif
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64)) bionic-benchmarks-run-on-host: bionic-benchmarks $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT_EXECUTABLES)/sh
bionic-benchmarks-run-on-host32: bionic-benchmarks bionic-prepare-run-on-host if [ ! -d /system -o ! -d /system/bin ]; then \
echo "Attempting to create /system/bin"; \
sudo mkdir -p -m 0777 /system/bin; \
fi
mkdir -p $(TARGET_OUT_DATA)/local/tmp
cp $(TARGET_OUT_EXECUTABLES)/$(LINKER) /system/bin
cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin
ANDROID_DATA=$(TARGET_OUT_DATA) \ ANDROID_DATA=$(TARGET_OUT_DATA) \
ANDROID_ROOT=$(TARGET_OUT) \ ANDROID_ROOT=$(TARGET_OUT) \
$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks32 $(BIONIC_BENCHMARKS_FLAGS) LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \
endif $(TARGET_OUT_EXECUTABLES)/bionic-benchmarks$(NATIVE_SUFFIX) $(BIONIC_BENCHMARKS_FLAGS)
endif # linux-x86
ifeq ($(TARGET_IS_64_BIT),true)
bionic-benchmarks-run-on-host64: bionic-benchmarks bionic-prepare-run-on-host
ANDROID_DATA=$(TARGET_OUT_DATA) \
ANDROID_ROOT=$(TARGET_OUT) \
$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks64 $(BIONIC_BENCHMARKS_FLAGS)
endif
endif
endif # !BUILD_TINY_ANDROID endif # !BUILD_TINY_ANDROID

View File

@@ -19,7 +19,6 @@
#include <regex.h> #include <regex.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#include <string> #include <string>
#include <map> #include <map>

View File

@@ -20,8 +20,8 @@
#include <math.h> #include <math.h>
// Avoid optimization. // Avoid optimization.
volatile double d; double d;
volatile double v; double v;
static void BM_math_sqrt(int iters) { static void BM_math_sqrt(int iters) {
StartBenchmarkTiming(); StartBenchmarkTiming();

View File

@@ -80,7 +80,7 @@ BENCHMARK(BM_pthread_mutex_lock);
static void BM_pthread_mutex_lock_ERRORCHECK(int iters) { static void BM_pthread_mutex_lock_ERRORCHECK(int iters) {
StopBenchmarkTiming(); StopBenchmarkTiming();
pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER;
StartBenchmarkTiming(); StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) { for (int i = 0; i < iters; ++i) {
@@ -94,7 +94,7 @@ BENCHMARK(BM_pthread_mutex_lock_ERRORCHECK);
static void BM_pthread_mutex_lock_RECURSIVE(int iters) { static void BM_pthread_mutex_lock_RECURSIVE(int iters) {
StopBenchmarkTiming(); StopBenchmarkTiming();
pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
StartBenchmarkTiming(); StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) { for (int i = 0; i < iters; ++i) {
@@ -105,35 +105,3 @@ static void BM_pthread_mutex_lock_RECURSIVE(int iters) {
StopBenchmarkTiming(); StopBenchmarkTiming();
} }
BENCHMARK(BM_pthread_mutex_lock_RECURSIVE); BENCHMARK(BM_pthread_mutex_lock_RECURSIVE);
static void BM_pthread_rw_lock_read(int iters) {
StopBenchmarkTiming();
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
pthread_rwlock_rdlock(&lock);
pthread_rwlock_unlock(&lock);
}
StopBenchmarkTiming();
pthread_rwlock_destroy(&lock);
}
BENCHMARK(BM_pthread_rw_lock_read);
static void BM_pthread_rw_lock_write(int iters) {
StopBenchmarkTiming();
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
pthread_rwlock_wrlock(&lock);
pthread_rwlock_unlock(&lock);
}
StopBenchmarkTiming();
pthread_rwlock_destroy(&lock);
}
BENCHMARK(BM_pthread_rw_lock_write);

View File

@@ -25,19 +25,14 @@
Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(8)->Arg(16)->Arg(32)->Arg(64)->Arg(512)-> \ Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(8)->Arg(16)->Arg(32)->Arg(64)->Arg(512)-> \
Arg(1*KB)->Arg(4*KB)->Arg(8*KB)->Arg(16*KB)->Arg(64*KB) Arg(1*KB)->Arg(4*KB)->Arg(8*KB)->Arg(16*KB)->Arg(64*KB)
template <typename Fn> static void BM_stdio_fread(int iters, int chunk_size) {
static void ReadWriteTest(int iters, int chunk_size, Fn f, bool buffered) {
StopBenchmarkTiming(); StopBenchmarkTiming();
FILE* fp = fopen("/dev/zero", "rw"); FILE* fp = fopen("/dev/zero", "rw");
char* buf = new char[chunk_size]; char* buf = new char[chunk_size];
StartBenchmarkTiming(); StartBenchmarkTiming();
if (!buffered) {
setvbuf(fp, 0, _IONBF, 0);
}
for (int i = 0; i < iters; ++i) { for (int i = 0; i < iters; ++i) {
f(buf, chunk_size, 1, fp); fread(buf, chunk_size, 1, fp);
} }
StopBenchmarkTiming(); StopBenchmarkTiming();
@@ -45,23 +40,22 @@ static void ReadWriteTest(int iters, int chunk_size, Fn f, bool buffered) {
delete[] buf; delete[] buf;
fclose(fp); fclose(fp);
} }
static void BM_stdio_fread(int iters, int chunk_size) {
ReadWriteTest(iters, chunk_size, fread, true);
}
BENCHMARK(BM_stdio_fread)->AT_COMMON_SIZES; BENCHMARK(BM_stdio_fread)->AT_COMMON_SIZES;
static void BM_stdio_fwrite(int iters, int chunk_size) { static void BM_stdio_fwrite(int iters, int chunk_size) {
ReadWriteTest(iters, chunk_size, fwrite, true); StopBenchmarkTiming();
FILE* fp = fopen("/dev/zero", "rw");
char* buf = new char[chunk_size];
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
fwrite(buf, chunk_size, 1, fp);
}
StopBenchmarkTiming();
SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(chunk_size));
delete[] buf;
fclose(fp);
} }
BENCHMARK(BM_stdio_fwrite)->AT_COMMON_SIZES; BENCHMARK(BM_stdio_fwrite)->AT_COMMON_SIZES;
static void BM_stdio_fread_unbuffered(int iters, int chunk_size) {
ReadWriteTest(iters, chunk_size, fread, false);
}
BENCHMARK(BM_stdio_fread_unbuffered)->AT_COMMON_SIZES;
static void BM_stdio_fwrite_unbuffered(int iters, int chunk_size) {
ReadWriteTest(iters, chunk_size, fwrite, false);
}
BENCHMARK(BM_stdio_fwrite_unbuffered)->AT_COMMON_SIZES;

View File

@@ -16,9 +16,7 @@
#include "benchmark.h" #include "benchmark.h"
#include <unistd.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/time.h>
#include <time.h> #include <time.h>
static void BM_time_clock_gettime(int iters) { static void BM_time_clock_gettime(int iters) {

View File

@@ -41,8 +41,6 @@ static void BM_unistd_getpid_syscall(int iters) {
} }
BENCHMARK(BM_unistd_getpid_syscall); BENCHMARK(BM_unistd_getpid_syscall);
#if defined(__BIONIC__)
// Stop GCC optimizing out our pure function. // Stop GCC optimizing out our pure function.
/* Must not be static! */ pid_t (*gettid_fp)() = gettid; /* Must not be static! */ pid_t (*gettid_fp)() = gettid;
@@ -57,8 +55,6 @@ static void BM_unistd_gettid(int iters) {
} }
BENCHMARK(BM_unistd_gettid); BENCHMARK(BM_unistd_gettid);
#endif
static void BM_unistd_gettid_syscall(int iters) { static void BM_unistd_gettid_syscall(int iters) {
StartBenchmarkTiming(); StartBenchmarkTiming();

View File

@@ -1,44 +0,0 @@
#
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed 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.
#
# Include once
ifneq ($(bionic_run_on_host_mk_included),true)
bionic_run_on_host_mk_included:=true
ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86))
LINKER = linker64
else
LINKER = linker
endif
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
# gtest needs ANDROID_DATA/local/tmp for death test output.
# Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
# bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT.
bionic-prepare-run-on-host: $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT)/etc/hosts $(TARGET_OUT_EXECUTABLES)/sh
if [ ! -d /system ]; then \
echo "Attempting to create /system"; \
sudo mkdir -p -m 0777 /system; \
fi
mkdir -p $(TARGET_OUT_DATA)/local/tmp
ln -fs `realpath $(TARGET_OUT)/bin` /system/
ln -fs `realpath $(TARGET_OUT)/etc` /system/
ln -fs `realpath $(TARGET_OUT)/lib` /system/
if [ -d "$(TARGET_OUT)/lib64" ]; then \
ln -fs `realpath $(TARGET_OUT)/lib64` /system/; \
fi
endif
endif

View File

@@ -1,7 +1,5 @@
LOCAL_PATH := $(call my-dir) LOCAL_PATH := $(call my-dir)
bionic_coverage := false
# Make everything depend on any changes to included makefiles. # Make everything depend on any changes to included makefiles.
libc_common_additional_dependencies := $(LOCAL_PATH)/Android.mk libc_common_additional_dependencies := $(LOCAL_PATH)/Android.mk
@@ -40,9 +38,12 @@ endif
# ========================================================= # =========================================================
libc_common_src_files := \ libc_common_src_files := \
bionic/bindresvport.c \ bionic/bindresvport.c \
bionic/daemon.c \
bionic/err.c \
bionic/ether_aton.c \ bionic/ether_aton.c \
bionic/ether_ntoa.c \ bionic/ether_ntoa.c \
bionic/fts.c \ bionic/fts.c \
bionic/gethostname.c \
bionic/getpriority.c \ bionic/getpriority.c \
bionic/if_indextoname.c \ bionic/if_indextoname.c \
bionic/if_nametoindex.c \ bionic/if_nametoindex.c \
@@ -50,9 +51,11 @@ libc_common_src_files := \
bionic/ioctl.c \ bionic/ioctl.c \
bionic/isatty.c \ bionic/isatty.c \
bionic/memmem.c \ bionic/memmem.c \
bionic/pathconf.c \
bionic/pututline.c \ bionic/pututline.c \
bionic/sched_cpualloc.c \ bionic/sched_cpualloc.c \
bionic/sched_cpucount.c \ bionic/sched_cpucount.c \
bionic/semaphore.c \
bionic/sigblock.c \ bionic/sigblock.c \
bionic/siginterrupt.c \ bionic/siginterrupt.c \
bionic/sigsetmask.c \ bionic/sigsetmask.c \
@@ -61,7 +64,6 @@ libc_common_src_files := \
stdio/fread.c \ stdio/fread.c \
stdio/snprintf.c\ stdio/snprintf.c\
stdio/sprintf.c \ stdio/sprintf.c \
stdio/stdio_ext.cpp \
# Fortify implementations of libc functions. # Fortify implementations of libc functions.
libc_common_src_files += \ libc_common_src_files += \
@@ -90,7 +92,6 @@ libc_bionic_src_files := \
bionic/access.cpp \ bionic/access.cpp \
bionic/assert.cpp \ bionic/assert.cpp \
bionic/atof.cpp \ bionic/atof.cpp \
bionic/bionic_systrace.cpp \
bionic/bionic_time_conversions.cpp \ bionic/bionic_time_conversions.cpp \
bionic/brk.cpp \ bionic/brk.cpp \
bionic/c16rtomb.cpp \ bionic/c16rtomb.cpp \
@@ -99,8 +100,6 @@ libc_bionic_src_files := \
bionic/chown.cpp \ bionic/chown.cpp \
bionic/clearenv.cpp \ bionic/clearenv.cpp \
bionic/clock.cpp \ bionic/clock.cpp \
bionic/clock_getcpuclockid.cpp \
bionic/clock_nanosleep.cpp \
bionic/clone.cpp \ bionic/clone.cpp \
bionic/__cmsg_nxthdr.cpp \ bionic/__cmsg_nxthdr.cpp \
bionic/connect.cpp \ bionic/connect.cpp \
@@ -121,11 +120,9 @@ libc_bionic_src_files := \
bionic/getauxval.cpp \ bionic/getauxval.cpp \
bionic/getcwd.cpp \ bionic/getcwd.cpp \
bionic/getentropy_linux.c \ bionic/getentropy_linux.c \
bionic/gethostname.cpp \
bionic/getpgrp.cpp \ bionic/getpgrp.cpp \
bionic/getpid.cpp \ bionic/getpid.cpp \
bionic/gettid.cpp \ bionic/gettid.cpp \
bionic/__gnu_basename.cpp \
bionic/inotify_init.cpp \ bionic/inotify_init.cpp \
bionic/lchown.cpp \ bionic/lchown.cpp \
bionic/lfs64_support.cpp \ bionic/lfs64_support.cpp \
@@ -137,7 +134,6 @@ libc_bionic_src_files := \
bionic/link.cpp \ bionic/link.cpp \
bionic/locale.cpp \ bionic/locale.cpp \
bionic/lstat.cpp \ bionic/lstat.cpp \
bionic/malloc_info.cpp \
bionic/mbrtoc16.cpp \ bionic/mbrtoc16.cpp \
bionic/mbrtoc32.cpp \ bionic/mbrtoc32.cpp \
bionic/mbstate.cpp \ bionic/mbstate.cpp \
@@ -147,13 +143,11 @@ libc_bionic_src_files := \
bionic/mntent.cpp \ bionic/mntent.cpp \
bionic/NetdClientDispatch.cpp \ bionic/NetdClientDispatch.cpp \
bionic/open.cpp \ bionic/open.cpp \
bionic/pathconf.cpp \
bionic/pause.cpp \ bionic/pause.cpp \
bionic/pipe.cpp \ bionic/pipe.cpp \
bionic/poll.cpp \ bionic/poll.cpp \
bionic/posix_fadvise.cpp \ bionic/posix_fadvise.cpp \
bionic/posix_fallocate.cpp \ bionic/posix_fallocate.cpp \
bionic/posix_madvise.cpp \
bionic/posix_timers.cpp \ bionic/posix_timers.cpp \
bionic/pthread_atfork.cpp \ bionic/pthread_atfork.cpp \
bionic/pthread_attr.cpp \ bionic/pthread_attr.cpp \
@@ -188,7 +182,6 @@ libc_bionic_src_files := \
bionic/scandir.cpp \ bionic/scandir.cpp \
bionic/sched_getaffinity.cpp \ bionic/sched_getaffinity.cpp \
bionic/sched_getcpu.cpp \ bionic/sched_getcpu.cpp \
bionic/semaphore.cpp \
bionic/send.cpp \ bionic/send.cpp \
bionic/setegid.cpp \ bionic/setegid.cpp \
bionic/__set_errno.cpp \ bionic/__set_errno.cpp \
@@ -204,22 +197,24 @@ libc_bionic_src_files := \
bionic/signalfd.cpp \ bionic/signalfd.cpp \
bionic/sigpending.cpp \ bionic/sigpending.cpp \
bionic/sigprocmask.cpp \ bionic/sigprocmask.cpp \
bionic/sigqueue.cpp \
bionic/sigsuspend.cpp \ bionic/sigsuspend.cpp \
bionic/sigtimedwait.cpp \
bionic/sigwait.cpp \ bionic/sigwait.cpp \
bionic/sigwaitinfo.cpp \
bionic/socket.cpp \ bionic/socket.cpp \
bionic/stat.cpp \ bionic/stat.cpp \
bionic/statvfs.cpp \ bionic/statvfs.cpp \
bionic/strcoll_l.cpp \
bionic/strerror.cpp \ bionic/strerror.cpp \
bionic/strerror_r.cpp \ bionic/strerror_r.cpp \
bionic/strftime_l.cpp \
bionic/strsignal.cpp \ bionic/strsignal.cpp \
bionic/strtold.cpp \ bionic/strtold.cpp \
bionic/strtold_l.cpp \
bionic/strtoll_l.cpp \
bionic/strtoull_l.cpp \
bionic/strxfrm_l.cpp \
bionic/stubs.cpp \ bionic/stubs.cpp \
bionic/symlink.cpp \ bionic/symlink.cpp \
bionic/sysconf.cpp \ bionic/sysconf.cpp \
bionic/sysinfo.cpp \
bionic/syslog.cpp \ bionic/syslog.cpp \
bionic/sys_siglist.c \ bionic/sys_siglist.c \
bionic/sys_signame.c \ bionic/sys_signame.c \
@@ -245,6 +240,9 @@ libc_upstream_freebsd_src_files := \
upstream-freebsd/lib/libc/gen/ldexp.c \ upstream-freebsd/lib/libc/gen/ldexp.c \
upstream-freebsd/lib/libc/gen/sleep.c \ upstream-freebsd/lib/libc/gen/sleep.c \
upstream-freebsd/lib/libc/gen/usleep.c \ upstream-freebsd/lib/libc/gen/usleep.c \
upstream-freebsd/lib/libc/stdio/fclose.c \
upstream-freebsd/lib/libc/stdio/flags.c \
upstream-freebsd/lib/libc/stdio/fopen.c \
upstream-freebsd/lib/libc/stdlib/abs.c \ upstream-freebsd/lib/libc/stdlib/abs.c \
upstream-freebsd/lib/libc/stdlib/getopt_long.c \ upstream-freebsd/lib/libc/stdlib/getopt_long.c \
upstream-freebsd/lib/libc/stdlib/imaxabs.c \ upstream-freebsd/lib/libc/stdlib/imaxabs.c \
@@ -290,8 +288,8 @@ libc_upstream_netbsd_src_files := \
upstream-netbsd/lib/libc/stdlib/div.c \ upstream-netbsd/lib/libc/stdlib/div.c \
upstream-netbsd/lib/libc/stdlib/drand48.c \ upstream-netbsd/lib/libc/stdlib/drand48.c \
upstream-netbsd/lib/libc/stdlib/erand48.c \ upstream-netbsd/lib/libc/stdlib/erand48.c \
upstream-netbsd/lib/libc/stdlib/insque.c \
upstream-netbsd/lib/libc/stdlib/jrand48.c \ upstream-netbsd/lib/libc/stdlib/jrand48.c \
upstream-netbsd/lib/libc/stdlib/lcong48.c \
upstream-netbsd/lib/libc/stdlib/ldiv.c \ upstream-netbsd/lib/libc/stdlib/ldiv.c \
upstream-netbsd/lib/libc/stdlib/lldiv.c \ upstream-netbsd/lib/libc/stdlib/lldiv.c \
upstream-netbsd/lib/libc/stdlib/lrand48.c \ upstream-netbsd/lib/libc/stdlib/lrand48.c \
@@ -299,12 +297,14 @@ libc_upstream_netbsd_src_files := \
upstream-netbsd/lib/libc/stdlib/nrand48.c \ upstream-netbsd/lib/libc/stdlib/nrand48.c \
upstream-netbsd/lib/libc/stdlib/_rand48.c \ upstream-netbsd/lib/libc/stdlib/_rand48.c \
upstream-netbsd/lib/libc/stdlib/rand_r.c \ upstream-netbsd/lib/libc/stdlib/rand_r.c \
upstream-netbsd/lib/libc/stdlib/remque.c \
upstream-netbsd/lib/libc/stdlib/seed48.c \ upstream-netbsd/lib/libc/stdlib/seed48.c \
upstream-netbsd/lib/libc/stdlib/srand48.c \ upstream-netbsd/lib/libc/stdlib/srand48.c \
upstream-netbsd/lib/libc/string/memccpy.c \ upstream-netbsd/lib/libc/string/memccpy.c \
upstream-netbsd/lib/libc/string/strcasestr.c \ upstream-netbsd/lib/libc/string/strcasestr.c \
upstream-netbsd/lib/libc/string/strcoll.c \ upstream-netbsd/lib/libc/string/strcoll.c \
upstream-netbsd/lib/libc/string/strxfrm.c \ upstream-netbsd/lib/libc/string/strxfrm.c \
upstream-netbsd/lib/libc/unistd/killpg.c \
libc_upstream_openbsd_gdtoa_src_files := \ libc_upstream_openbsd_gdtoa_src_files := \
upstream-openbsd/android/gdtoa_support.cpp \ upstream-openbsd/android/gdtoa_support.cpp \
@@ -334,14 +334,10 @@ libc_upstream_openbsd_gdtoa_src_files_64 := \
upstream-openbsd/lib/libc/gdtoa/strtorQ.c \ upstream-openbsd/lib/libc/gdtoa/strtorQ.c \
libc_upstream_openbsd_src_files := \ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/compat-43/killpg.c \
upstream-openbsd/lib/libc/crypt/arc4random.c \ upstream-openbsd/lib/libc/crypt/arc4random.c \
upstream-openbsd/lib/libc/crypt/arc4random_uniform.c \ upstream-openbsd/lib/libc/crypt/arc4random_uniform.c \
upstream-openbsd/lib/libc/gen/alarm.c \ upstream-openbsd/lib/libc/gen/alarm.c \
upstream-openbsd/lib/libc/gen/ctype_.c \ upstream-openbsd/lib/libc/gen/ctype_.c \
upstream-openbsd/lib/libc/gen/daemon.c \
upstream-openbsd/lib/libc/gen/err.c \
upstream-openbsd/lib/libc/gen/errx.c \
upstream-openbsd/lib/libc/gen/exec.c \ upstream-openbsd/lib/libc/gen/exec.c \
upstream-openbsd/lib/libc/gen/fnmatch.c \ upstream-openbsd/lib/libc/gen/fnmatch.c \
upstream-openbsd/lib/libc/gen/ftok.c \ upstream-openbsd/lib/libc/gen/ftok.c \
@@ -351,12 +347,6 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/gen/time.c \ upstream-openbsd/lib/libc/gen/time.c \
upstream-openbsd/lib/libc/gen/tolower_.c \ upstream-openbsd/lib/libc/gen/tolower_.c \
upstream-openbsd/lib/libc/gen/toupper_.c \ upstream-openbsd/lib/libc/gen/toupper_.c \
upstream-openbsd/lib/libc/gen/verr.c \
upstream-openbsd/lib/libc/gen/verrx.c \
upstream-openbsd/lib/libc/gen/vwarn.c \
upstream-openbsd/lib/libc/gen/vwarnx.c \
upstream-openbsd/lib/libc/gen/warn.c \
upstream-openbsd/lib/libc/gen/warnx.c \
upstream-openbsd/lib/libc/locale/btowc.c \ upstream-openbsd/lib/libc/locale/btowc.c \
upstream-openbsd/lib/libc/locale/mbrlen.c \ upstream-openbsd/lib/libc/locale/mbrlen.c \
upstream-openbsd/lib/libc/locale/mbstowcs.c \ upstream-openbsd/lib/libc/locale/mbstowcs.c \
@@ -390,7 +380,6 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/asprintf.c \ upstream-openbsd/lib/libc/stdio/asprintf.c \
upstream-openbsd/lib/libc/stdio/clrerr.c \ upstream-openbsd/lib/libc/stdio/clrerr.c \
upstream-openbsd/lib/libc/stdio/dprintf.c \ upstream-openbsd/lib/libc/stdio/dprintf.c \
upstream-openbsd/lib/libc/stdio/fclose.c \
upstream-openbsd/lib/libc/stdio/fdopen.c \ upstream-openbsd/lib/libc/stdio/fdopen.c \
upstream-openbsd/lib/libc/stdio/feof.c \ upstream-openbsd/lib/libc/stdio/feof.c \
upstream-openbsd/lib/libc/stdio/ferror.c \ upstream-openbsd/lib/libc/stdio/ferror.c \
@@ -402,9 +391,6 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/fgetwc.c \ upstream-openbsd/lib/libc/stdio/fgetwc.c \
upstream-openbsd/lib/libc/stdio/fgetws.c \ upstream-openbsd/lib/libc/stdio/fgetws.c \
upstream-openbsd/lib/libc/stdio/fileno.c \ upstream-openbsd/lib/libc/stdio/fileno.c \
upstream-openbsd/lib/libc/stdio/flags.c \
upstream-openbsd/lib/libc/stdio/fmemopen.c \
upstream-openbsd/lib/libc/stdio/fopen.c \
upstream-openbsd/lib/libc/stdio/fprintf.c \ upstream-openbsd/lib/libc/stdio/fprintf.c \
upstream-openbsd/lib/libc/stdio/fpurge.c \ upstream-openbsd/lib/libc/stdio/fpurge.c \
upstream-openbsd/lib/libc/stdio/fputc.c \ upstream-openbsd/lib/libc/stdio/fputc.c \
@@ -432,8 +418,6 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/getwchar.c \ upstream-openbsd/lib/libc/stdio/getwchar.c \
upstream-openbsd/lib/libc/stdio/makebuf.c \ upstream-openbsd/lib/libc/stdio/makebuf.c \
upstream-openbsd/lib/libc/stdio/mktemp.c \ upstream-openbsd/lib/libc/stdio/mktemp.c \
upstream-openbsd/lib/libc/stdio/open_memstream.c \
upstream-openbsd/lib/libc/stdio/open_wmemstream.c \
upstream-openbsd/lib/libc/stdio/perror.c \ upstream-openbsd/lib/libc/stdio/perror.c \
upstream-openbsd/lib/libc/stdio/printf.c \ upstream-openbsd/lib/libc/stdio/printf.c \
upstream-openbsd/lib/libc/stdio/putc.c \ upstream-openbsd/lib/libc/stdio/putc.c \
@@ -482,10 +466,7 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdlib/atoll.c \ upstream-openbsd/lib/libc/stdlib/atoll.c \
upstream-openbsd/lib/libc/stdlib/exit.c \ upstream-openbsd/lib/libc/stdlib/exit.c \
upstream-openbsd/lib/libc/stdlib/getenv.c \ upstream-openbsd/lib/libc/stdlib/getenv.c \
upstream-openbsd/lib/libc/stdlib/insque.c \
upstream-openbsd/lib/libc/stdlib/lsearch.c \ upstream-openbsd/lib/libc/stdlib/lsearch.c \
upstream-openbsd/lib/libc/stdlib/reallocarray.c \
upstream-openbsd/lib/libc/stdlib/remque.c \
upstream-openbsd/lib/libc/stdlib/setenv.c \ upstream-openbsd/lib/libc/stdlib/setenv.c \
upstream-openbsd/lib/libc/stdlib/strtoimax.c \ upstream-openbsd/lib/libc/stdlib/strtoimax.c \
upstream-openbsd/lib/libc/stdlib/strtol.c \ upstream-openbsd/lib/libc/stdlib/strtol.c \
@@ -554,6 +535,13 @@ ifneq ($(BOARD_MALLOC_ALIGNMENT),)
libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT) libc_common_cflags += -DMALLOC_ALIGNMENT=$(BOARD_MALLOC_ALIGNMENT)
endif endif
# Define ANDROID_SMP appropriately.
ifeq ($(TARGET_CPU_SMP),true)
libc_common_cflags += -DANDROID_SMP=1
else
libc_common_cflags += -DANDROID_SMP=0
endif
# Define some common conlyflags # Define some common conlyflags
libc_common_conlyflags := \ libc_common_conlyflags := \
-std=gnu99 -std=gnu99
@@ -598,10 +586,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_stack_protector LOCAL_MODULE := libc_stack_protector
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -639,10 +624,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes) $(LOCAL_PATH)/tzcode/
LOCAL_MODULE := libc_tzcode LOCAL_MODULE := libc_tzcode
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -660,13 +642,7 @@ LOCAL_SRC_FILES := \
upstream-netbsd/lib/libc/isc/ev_timers.c \ upstream-netbsd/lib/libc/isc/ev_timers.c \
upstream-netbsd/lib/libc/resolv/mtctxres.c \ upstream-netbsd/lib/libc/resolv/mtctxres.c \
# We use the OpenBSD res_random. LOCAL_CFLAGS := \
LOCAL_CFLAGS += \
-Dres_randomid=__res_randomid
LOCAL_SRC_FILES += \
upstream-openbsd/lib/libc/net/res_random.c \
LOCAL_CFLAGS += \
$(libc_common_cflags) \ $(libc_common_cflags) \
-DANDROID_CHANGES \ -DANDROID_CHANGES \
-DINET6 \ -DINET6 \
@@ -684,10 +660,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_dns LOCAL_MODULE := libc_dns
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -716,10 +689,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_freebsd LOCAL_MODULE := libc_freebsd
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_freebsd_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_freebsd_src_files))
@@ -750,10 +720,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_netbsd LOCAL_MODULE := libc_netbsd
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_netbsd_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_netbsd_src_files))
@@ -779,9 +746,7 @@ endif
LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
$(libc_common_cflags) \ $(libc_common_cflags) \
-Wno-sign-compare \ -Wno-sign-compare -Wno-uninitialized -Wno-unused-parameter \
-Wno-uninitialized \
-Wno-unused-parameter \
-I$(LOCAL_PATH)/private \ -I$(LOCAL_PATH)/private \
-I$(LOCAL_PATH)/upstream-openbsd/android/include \ -I$(LOCAL_PATH)/upstream-openbsd/android/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \ -I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
@@ -793,10 +758,7 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_openbsd LOCAL_MODULE := libc_openbsd
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_openbsd_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_openbsd_src_files))
@@ -835,10 +797,7 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_gdtoa LOCAL_MODULE := libc_gdtoa
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -854,23 +813,18 @@ LOCAL_SRC_FILES := $(libc_bionic_src_files)
LOCAL_CFLAGS := $(libc_common_cflags) \ LOCAL_CFLAGS := $(libc_common_cflags) \
-Wframe-larger-than=2048 \ -Wframe-larger-than=2048 \
# ssse3-strcmp-slm.S does not compile with Clang. ifeq ($(TARGET_ARCH),x86_64)
LOCAL_CLANG_ASFLAGS_x86_64 += -no-integrated-as # Clang assembler has problem with ssse3-strcmp-slm.S, http://b/17302991
LOCAL_CLANG_ASFLAGS += -no-integrated-as
# memcpy.S, memchr.S, etc. do not compile with Clang. endif
LOCAL_CLANG_ASFLAGS_arm += -no-integrated-as
LOCAL_CLANG_ASFLAGS_arm64 += -no-integrated-as
LOCAL_CONLYFLAGS := $(libc_common_conlyflags) LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_bionic LOCAL_MODULE := libc_bionic
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_bionic_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_bionic_src_files))
@@ -889,14 +843,12 @@ LOCAL_CFLAGS := $(libc_common_cflags) \
LOCAL_CONLYFLAGS := $(libc_common_conlyflags) LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_cxa LOCAL_MODULE := libc_cxa
LOCAL_CLANG := true # GCC refuses to hide new/delete # GCC refuses to hide new/delete
LOCAL_CLANG := true
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -914,10 +866,7 @@ endif
LOCAL_MODULE := libc_syscalls LOCAL_MODULE := libc_syscalls
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -936,10 +885,7 @@ LOCAL_MODULE := libc_aeabi
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_CFLAGS := $(libc_common_cflags) -fno-builtin LOCAL_CFLAGS := $(libc_common_cflags) -fno-builtin
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -976,13 +922,10 @@ ifneq ($(MALLOC_IMPL),dlmalloc)
LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc
endif endif
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
# TODO: split out the asflags. # TODO: split out the asflags.
LOCAL_ASFLAGS := $(LOCAL_CFLAGS) LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_common_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_common_src_files))
@@ -1018,10 +961,7 @@ LOCAL_MODULE := libc_nomalloc
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
@@ -1042,9 +982,6 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes) LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_malloc LOCAL_MODULE := libc_malloc
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_CXX_STL := none
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@@ -1070,10 +1007,7 @@ LOCAL_MODULE := libc
LOCAL_CLANG := $(use_clang) LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files)) $(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
@@ -1115,7 +1049,6 @@ LOCAL_STRIP_MODULE := keep_symbols
LOCAL_SHARED_LIBRARIES := libdl LOCAL_SHARED_LIBRARIES := libdl
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
# We'd really like to do this for all architectures, but since this wasn't done # We'd really like to do this for all architectures, but since this wasn't done
@@ -1135,8 +1068,6 @@ LOCAL_SRC_FILES_arm += \
arch-common/bionic/crtbegin_so.c \ arch-common/bionic/crtbegin_so.c \
arch-arm/bionic/atexit_legacy.c \ arch-arm/bionic/atexit_legacy.c \
arch-common/bionic/crtend_so.S arch-common/bionic/crtend_so.S
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
@@ -1154,7 +1085,10 @@ ifneq ($(TARGET_BUILD_VARIANT),user)
# ======================================================== # ========================================================
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CFLAGS := $(libc_common_cflags) LOCAL_CFLAGS := \
$(libc_common_cflags) \
-DMALLOC_LEAK_CHECK \
LOCAL_CONLYFLAGS := $(libc_common_conlyflags) LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_CPPFLAGS := $(libc_common_cppflags)
@@ -1174,17 +1108,14 @@ LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SHARED_LIBRARIES := libc libdl LOCAL_SHARED_LIBRARIES := libc libdl
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
# Only need this for arm since libc++ uses its own unwind code that # Only need this for arm since libc++ uses its own unwind code that
# doesn't mix with the other default unwind code. # doesn't mix with the other default unwind code.
LOCAL_STATIC_LIBRARIES_arm := libunwind_llvm libc++abi LOCAL_STATIC_LIBRARIES_arm := libc++
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
# Don't install on release build # Don't install on release build
LOCAL_MODULE_TAGS := eng debug LOCAL_MODULE_TAGS := eng debug
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
@@ -1213,13 +1144,10 @@ LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies) LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SHARED_LIBRARIES := libc libdl LOCAL_SHARED_LIBRARIES := libc libdl
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_SYSTEM_SHARED_LIBRARIES :=
# Don't install on release build # Don't install on release build
LOCAL_MODULE_TAGS := eng debug LOCAL_MODULE_TAGS := eng debug
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags)) $(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
@@ -1236,32 +1164,26 @@ libstdcxx_common_src_files := \
bionic/libc_logging.cpp \ bionic/libc_logging.cpp \
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_CFLAGS := $(libc_common_cflags) LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_SRC_FILES := $(libstdcxx_common_src_files) LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
LOCAL_MODULE:= libstdc++ LOCAL_MODULE:= libstdc++
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := libc LOCAL_SYSTEM_SHARED_LIBRARIES := libc
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
# ======================================================== # ========================================================
# libstdc++.a # libstdc++.a
# ======================================================== # ========================================================
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_CFLAGS := $(libc_common_cflags) LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags) LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_SRC_FILES := $(libstdcxx_common_src_files) LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
LOCAL_MODULE:= libstdc++ LOCAL_MODULE:= libstdc++
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := libc LOCAL_SYSTEM_SHARED_LIBRARIES := libc
LOCAL_ADDRESS_SANITIZER := false
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)

View File

@@ -2539,6 +2539,35 @@ SUCH DAMAGE.
------------------------------------------------------------------- -------------------------------------------------------------------
Copyright (c) 1993
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
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. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
-------------------------------------------------------------------
Copyright (c) 1993 Christopher G. Demetriou Copyright (c) 1993 Christopher G. Demetriou
All rights reserved. All rights reserved.
@@ -3102,6 +3131,38 @@ SUCH DAMAGE.
------------------------------------------------------------------- -------------------------------------------------------------------
Copyright (c) 1999 Kungliga Tekniska Högskolan
(Royal Institute of Technology, Stockholm, Sweden).
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
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. Neither the name of KTH nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY KTH AND ITS 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 KTH OR ITS 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
-------------------------------------------------------------------
Copyright (c) 2000 Ben Harris. Copyright (c) 2000 Ben Harris.
Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
All rights reserved. All rights reserved.
@@ -4361,39 +4422,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------- -------------------------------------------------------------------
Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------
Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
Copyright (c) 2009 Ted Unangst
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------
Copyright (c) 2011 The Android Open Source Project Copyright (c) 2011 The Android Open Source Project
Copyright (c) 2008 ARM Ltd Copyright (c) 2008 ARM Ltd
All rights reserved. All rights reserved.
@@ -4825,42 +4853,6 @@ SUCH DAMAGE.
------------------------------------------------------------------- -------------------------------------------------------------------
Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
Copyright 2008 Damien Miller <djm@openbsd.org>
All rights reserved.
Theo de Raadt <deraadt@openbsd.org> came up with the idea of using
such a mathematical system to generate more random (yet non-repeating)
ids to solve the resolver/named problem. But Niels designed the
actual system based on the constraints.
Later modified by Damien Miller to wrap the LCG output in a 15-bit
permutation generator based on a Luby-Rackoff block cipher. This
ensures the output is non-repeating and preserves the MSB twiddle
trick, but makes it more resistant to LCG prediction.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
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.
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.
-------------------------------------------------------------------
Copyright 2000 David E. O'Brien, John D. Polstra. Copyright 2000 David E. O'Brien, John D. Polstra.
All rights reserved. All rights reserved.

View File

@@ -101,7 +101,7 @@ int munmap(void*, size_t) all
void* mremap(void*, size_t, size_t, unsigned long) all void* mremap(void*, size_t, size_t, unsigned long) all
int msync(const void*, size_t, int) all int msync(const void*, size_t, int) all
int mprotect(const void*, size_t, int) all int mprotect(const void*, size_t, int) all
int madvise(void*, size_t, int) all int madvise(const void*, size_t, int) all
int mlock(const void* addr, size_t len) all int mlock(const void* addr, size_t len) all
int munlock(const void* addr, size_t len) all int munlock(const void* addr, size_t len) all
int mlockall(int flags) all int mlockall(int flags) all
@@ -202,9 +202,9 @@ int swapoff(const char*) all
int settimeofday(const struct timeval*, const struct timezone*) all int settimeofday(const struct timeval*, const struct timezone*) all
clock_t times(struct tms*) all clock_t times(struct tms*) all
int nanosleep(const struct timespec*, struct timespec*) all int nanosleep(const struct timespec*, struct timespec*) all
int clock_settime(clockid_t, const struct timespec*) all int clock_settime(clockid_t clk_id, const struct timespec* tp) all
int clock_getres(clockid_t, struct timespec*) all int clock_getres(clockid_t clk_id, struct timespec* res) all
int __clock_nanosleep:clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*) all int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec* req, struct timespec* rem) all
int getitimer(int, const struct itimerval*) all int getitimer(int, const struct itimerval*) all
int setitimer(int, const struct itimerval*, struct itimerval*) all int setitimer(int, const struct itimerval*, struct itimerval*) all
int __timer_create:timer_create(clockid_t clockid, struct sigevent* evp, __kernel_timer_t* timerid) all int __timer_create:timer_create(clockid_t clockid, struct sigevent* evp, __kernel_timer_t* timerid) all
@@ -223,7 +223,6 @@ int __rt_sigpending:rt_sigpending(sigset_t*, size_t) all
int __rt_sigprocmask:rt_sigprocmask(int, const sigset_t*, sigset_t*, size_t) all int __rt_sigprocmask:rt_sigprocmask(int, const sigset_t*, sigset_t*, size_t) all
int __rt_sigsuspend:rt_sigsuspend(const sigset_t*, size_t) all int __rt_sigsuspend:rt_sigsuspend(const sigset_t*, size_t) all
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t*, struct siginfo_t*, struct timespec_t*, size_t) all int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t*, struct siginfo_t*, struct timespec_t*, size_t) all
int __rt_sigqueueinfo:rt_sigqueueinfo(pid_t, int, siginfo_t*) all
int __signalfd4:signalfd4(int, const sigset_t*, size_t, int) all int __signalfd4:signalfd4(int, const sigset_t*, size_t, int) all
# sockets # sockets
@@ -314,8 +313,6 @@ int __set_tid_address:set_tid_address(int*) all
int setfsgid(gid_t) all int setfsgid(gid_t) all
int setfsuid(uid_t) all int setfsuid(uid_t) all
int sethostname(const char*, size_t) all
pid_t wait4(pid_t, int*, int, struct rusage*) all pid_t wait4(pid_t, int*, int, struct rusage*) all
int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all int __waitid:waitid(int, pid_t, struct siginfo_t*, int, void*) all
@@ -324,7 +321,7 @@ int __set_tls:__ARM_NR_set_tls(void*) arm
int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) arm int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) arm
# MIPS-specific # MIPS-specific
int _flush_cache:cacheflush(char* addr, const int nbytes, const int op) mips int _flush_cache:cacheflush(char* addr, const int nbytes, const int op) mips,mips64
int __set_tls:set_thread_area(void*) mips,mips64 int __set_tls:set_thread_area(void*) mips,mips64
# x86-specific # x86-specific

View File

@@ -60,7 +60,9 @@ libc_bionic_src_files_arm += \
arch-arm/bionic/libgcc_compat.c \ arch-arm/bionic/libgcc_compat.c \
arch-arm/bionic/memcmp.S \ arch-arm/bionic/memcmp.S \
arch-arm/bionic/__restore.S \ arch-arm/bionic/__restore.S \
arch-arm/bionic/_setjmp.S \
arch-arm/bionic/setjmp.S \ arch-arm/bionic/setjmp.S \
arch-arm/bionic/sigsetjmp.S \
arch-arm/bionic/syscall.S \ arch-arm/bionic/syscall.S \
libc_arch_static_src_files_arm := arch-arm/bionic/exidx_static.c libc_arch_static_src_files_arm := arch-arm/bionic/exidx_static.c

View File

@@ -39,9 +39,6 @@
extern int __cxa_atexit(void (*)(void*), void*, void*); extern int __cxa_atexit(void (*)(void*), void*, void*);
// All of these are weak symbols to avoid multiple definition errors when
// linking with libstdc++-v3 or compiler-rt.
/* The "C++ ABI for ARM" document states that static C++ constructors, /* The "C++ ABI for ARM" document states that static C++ constructors,
* which are called from the .init_array, should manually call * which are called from the .init_array, should manually call
* __aeabi_atexit() to register static destructors explicitly. * __aeabi_atexit() to register static destructors explicitly.
@@ -50,35 +47,35 @@ extern int __cxa_atexit(void (*)(void*), void*, void*);
* variable from the shared object that contains the constructor/destructor * variable from the shared object that contains the constructor/destructor
*/ */
// Make this a weak symbol to avoid a multiple definition error when linking with libstdc++-v3.
int __attribute__((weak)) int __attribute__((weak))
__aeabi_atexit(void *object, void (*destructor) (void *), void *dso_handle) { __aeabi_atexit(void *object, void (*destructor) (void *), void *dso_handle) {
return __cxa_atexit(destructor, object, dso_handle); return __cxa_atexit(destructor, object, dso_handle);
} }
void __attribute__((weak)) void __aeabi_memcpy8(void *dest, const void *src, size_t n) {
__aeabi_memcpy8(void *dest, const void *src, size_t n) {
memcpy(dest, src, n); memcpy(dest, src, n);
} }
void __attribute__((weak)) __aeabi_memcpy4(void *dest, const void *src, size_t n) { void __aeabi_memcpy4(void *dest, const void *src, size_t n) {
memcpy(dest, src, n); memcpy(dest, src, n);
} }
void __attribute__((weak)) __aeabi_memcpy(void *dest, const void *src, size_t n) { void __aeabi_memcpy(void *dest, const void *src, size_t n) {
memcpy(dest, src, n); memcpy(dest, src, n);
} }
void __attribute__((weak)) __aeabi_memmove8(void *dest, const void *src, size_t n) { void __aeabi_memmove8(void *dest, const void *src, size_t n) {
memmove(dest, src, n); memmove(dest, src, n);
} }
void __attribute__((weak)) __aeabi_memmove4(void *dest, const void *src, size_t n) { void __aeabi_memmove4(void *dest, const void *src, size_t n) {
memmove(dest, src, n); memmove(dest, src, n);
} }
void __attribute__((weak)) __aeabi_memmove(void *dest, const void *src, size_t n) { void __aeabi_memmove(void *dest, const void *src, size_t n) {
memmove(dest, src, n); memmove(dest, src, n);
} }
@@ -87,27 +84,27 @@ void __attribute__((weak)) __aeabi_memmove(void *dest, const void *src, size_t n
* This allows __aeabi_memclr to tail-call __aeabi_memset * This allows __aeabi_memclr to tail-call __aeabi_memset
*/ */
void __attribute__((weak)) __aeabi_memset8(void *dest, size_t n, int c) { void __aeabi_memset8(void *dest, size_t n, int c) {
memset(dest, c, n); memset(dest, c, n);
} }
void __attribute__((weak)) __aeabi_memset4(void *dest, size_t n, int c) { void __aeabi_memset4(void *dest, size_t n, int c) {
memset(dest, c, n); memset(dest, c, n);
} }
void __attribute__((weak)) __aeabi_memset(void *dest, size_t n, int c) { void __aeabi_memset(void *dest, size_t n, int c) {
memset(dest, c, n); memset(dest, c, n);
} }
void __attribute__((weak)) __aeabi_memclr8(void *dest, size_t n) { void __aeabi_memclr8(void *dest, size_t n) {
__aeabi_memset8(dest, n, 0); __aeabi_memset8(dest, n, 0);
} }
void __attribute__((weak)) __aeabi_memclr4(void *dest, size_t n) { void __aeabi_memclr4(void *dest, size_t n) {
__aeabi_memset4(dest, n, 0); __aeabi_memset4(dest, n, 0);
} }
void __attribute__((weak)) __aeabi_memclr(void *dest, size_t n) { void __aeabi_memclr(void *dest, size_t n) {
__aeabi_memset(dest, n, 0); __aeabi_memset(dest, n, 0);
} }

View File

@@ -42,14 +42,13 @@ ENTRY(__bionic_clone)
# load extra parameters # load extra parameters
ldmfd ip, {r4, r5, r6} ldmfd ip, {r4, r5, r6}
# Push 'fn' and 'arg' onto the child stack. # store 'fn' and 'arg' to the child stack
stmdb r1!, {r5, r6} str r5, [r1, #-4]
str r6, [r1, #-8]
# Make the system call. # System call
ldr r7, =__NR_clone ldr r7, =__NR_clone
swi #0 swi #0
# Are we the child?
movs r0, r0 movs r0, r0
beq 1f beq 1f
@@ -63,8 +62,8 @@ ENTRY(__bionic_clone)
1: # The child. 1: # The child.
# Setting lr to 0 will make the unwinder stop at __start_thread # Setting lr to 0 will make the unwinder stop at __start_thread
mov lr, #0 mov lr, #0
# Call __start_thread with the 'fn' and 'arg' we stored on the child stack. ldr r0, [sp, #-4]
pop {r0, r1} ldr r1, [sp, #-8]
b __start_thread b __start_thread
END(__bionic_clone) END(__bionic_clone)
.hidden __bionic_clone .hidden __bionic_clone

View File

@@ -0,0 +1,113 @@
/* $OpenBSD: _setjmp.S,v 1.2 2004/02/01 05:40:52 drahn Exp $ */
/* $NetBSD: _setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
* Copyright (c) 2010 Android Open Source Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Mark Brinicombe
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#include <private/bionic_asm.h>
#include <machine/setjmp.h>
#include <machine/cpu-features.h>
/*
* C library -- _setjmp, _longjmp
*
* _longjmp(a,v)
* will generate a "return(v)" from the last call to
* _setjmp(a)
* by restoring registers from the stack.
* The previous signal state is NOT restored.
*
* Note: r0 is the return value
* r1-r3 are scratch registers in functions
*/
ENTRY(_setjmp)
ldr r1, .L_setjmp_magic
str r1, [r0, #(_JB_MAGIC * 4)]
/* Store core registers */
add r1, r0, #(_JB_CORE_BASE * 4)
stmia r1, {r4-r14}
#ifdef __ARM_HAVE_VFP
/* Store floating-point registers */
add r1, r0, #(_JB_FLOAT_BASE * 4)
vstmia r1, {d8-d15}
/* Store floating-point state */
fmrx r1, fpscr
str r1, [r0, #(_JB_FLOAT_STATE * 4)]
#endif /* __ARM_HAVE_VFP */
mov r0, #0x00000000
bx lr
END(_setjmp)
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
ENTRY(_longjmp)
ldr r2, .L_setjmp_magic
ldr r3, [r0, #(_JB_MAGIC * 4)]
teq r2, r3
bne botch
#ifdef __ARM_HAVE_VFP
/* Restore floating-point registers */
add r2, r0, #(_JB_FLOAT_BASE * 4)
vldmia r2, {d8-d15}
/* Restore floating-point state */
ldr r2, [r0, #(_JB_FLOAT_STATE * 4)]
fmxr fpscr, r2
#endif /* __ARM_HAVE_VFP */
/* Restore core registers */
add r2, r0, #(_JB_CORE_BASE * 4)
ldmia r2, {r4-r14}
/* Validate sp and r14 */
teq sp, #0
teqne r14, #0
beq botch
/* Set return value */
mov r0, r1
teq r0, #0x00000000
moveq r0, #0x00000001
bx lr
/* validation failed, die die die. */
botch:
bl PIC_SYM(longjmperror, PLT)
bl PIC_SYM(abort, PLT)
b . - 8 /* Cannot get here */
END(_longjmp)

View File

@@ -40,5 +40,5 @@ ENTRY(abort)
.cfi_def_cfa_offset 8 .cfi_def_cfa_offset 8
.cfi_rel_offset r3, 0 .cfi_rel_offset r3, 0
.cfi_rel_offset r14, 4 .cfi_rel_offset r14, 4
bl __libc_android_abort bl PIC_SYM(__libc_android_abort, PLT)
END(abort) END(abort)

View File

@@ -1,3 +1,6 @@
/* $OpenBSD: setjmp.S,v 1.2 2004/02/01 05:40:52 drahn Exp $ */
/* $NetBSD: setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $ */
/* /*
* Copyright (c) 1997 Mark Brinicombe * Copyright (c) 1997 Mark Brinicombe
* Copyright (c) 2010 Android Open Source Project. * Copyright (c) 2010 Android Open Source Project.
@@ -32,144 +35,119 @@
*/ */
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
#include <machine/setjmp.h>
#include <machine/cpu-features.h>
// According to the ARM AAPCS document, we only need to save /*
// the following registers: * C library -- setjmp, longjmp
// *
// Core r4-r14 * longjmp(a,v)
// * will generate a "return(v)" from the last call to
// VFP d8-d15 (see section 5.1.2.1) * setjmp(a)
// * by restoring registers from the stack.
// Registers s16-s31 (d8-d15, q4-q7) must be preserved across subroutine * The previous signal state is restored.
// calls; registers s0-s15 (d0-d7, q0-q3) do not need to be preserved */
// (and can be used for passing arguments or returning results in standard
// procedure-call variants). Registers d16-d31 (q8-q15), if present, do
// not need to be preserved.
//
// FPSCR saved because glibc does.
// The internal structure of a jmp_buf is totally private.
// Current layout (may change in the future):
//
// word name description
// 0 magic magic number
// 1 sigmask signal mask (not used with _setjmp / _longjmp)
// 2 float_base base of float registers (d8 to d15)
// 18 float_state floating-point status and control register
// 19 core_base base of core registers (r4 to r14)
// 30 reserved reserved entries (room to grow)
// 64
//
// NOTE: float_base must be at an even word index, since the
// FP registers will be loaded/stored with instructions
// that expect 8-byte alignment.
#define _JB_SIGFLAG 0
#define _JB_SIGMASK (_JB_SIGFLAG+1)
#define _JB_FLOAT_BASE (_JB_SIGMASK+1)
#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2)
#define _JB_CORE_BASE (_JB_FLOAT_STATE+1)
ENTRY(setjmp) ENTRY(setjmp)
mov r1, #1 /* Block all signals and retrieve the old signal mask */
b sigsetjmp
END(setjmp)
ENTRY(_setjmp)
mov r1, #0
b sigsetjmp
END(_setjmp)
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
ENTRY(sigsetjmp)
// Record whether or not we're saving the signal mask.
str r1, [r0, #(_JB_SIGFLAG * 4)]
// Do we need to save the signal mask?
teq r1, #0
beq 1f
// Get current signal mask.
stmfd sp!, {r0, r14} stmfd sp!, {r0, r14}
.cfi_def_cfa_offset 8 .cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0 .cfi_rel_offset r0, 0
.cfi_rel_offset r14, 4 .cfi_rel_offset r14, 4
mov r0, #0 mov r0, #0x00000000
bl sigblock
bl PIC_SYM(sigblock, PLT)
mov r1, r0 mov r1, r0
ldmfd sp!, {r0, r14} ldmfd sp!, {r0, r14}
.cfi_def_cfa_offset 0 .cfi_def_cfa_offset 0
// Save the signal mask. /* Store signal mask */
str r1, [r0, #(_JB_SIGMASK * 4)] str r1, [r0, #(_JB_SIGMASK * 4)]
1: ldr r1, .Lsetjmp_magic
// Save core registers. str r1, [r0, #(_JB_MAGIC * 4)]
/* Store core registers */
add r1, r0, #(_JB_CORE_BASE * 4) add r1, r0, #(_JB_CORE_BASE * 4)
stmia r1, {r4-r14} stmia r1, {r4-r14}
// Save floating-point registers. #ifdef __ARM_HAVE_VFP
/* Store floating-point registers */
add r1, r0, #(_JB_FLOAT_BASE * 4) add r1, r0, #(_JB_FLOAT_BASE * 4)
vstmia r1, {d8-d15} vstmia r1, {d8-d15}
/* Store floating-point state */
// Save floating-point state.
fmrx r1, fpscr fmrx r1, fpscr
str r1, [r0, #(_JB_FLOAT_STATE * 4)] str r1, [r0, #(_JB_FLOAT_STATE * 4)]
#endif /* __ARM_HAVE_VFP */
mov r0, #0 mov r0, #0x00000000
bx lr bx lr
END(sigsetjmp) END(setjmp)
// void siglongjmp(sigjmp_buf env, int value); .Lsetjmp_magic:
ENTRY(siglongjmp) .word _JB_MAGIC_SETJMP
// Do we need to restore the signal mask?
ldr r2, [r0, #(_JB_SIGFLAG * 4)]
teq r2, #0
beq 1f
// Restore the signal mask.
ENTRY(longjmp)
ldr r2, .Lsetjmp_magic
ldr r3, [r0, #(_JB_MAGIC * 4)]
teq r2, r3
bne botch
/* Fetch signal mask */
ldr r2, [r0, #(_JB_SIGMASK * 4)]
/* Set signal mask */
stmfd sp!, {r0, r1, r14} stmfd sp!, {r0, r1, r14}
.cfi_def_cfa_offset 12 .cfi_def_cfa_offset 12
.cfi_rel_offset r0, 0 .cfi_rel_offset r0, 0
.cfi_rel_offset r1, 4 .cfi_rel_offset r1, 4
.cfi_rel_offset r14, 8 .cfi_rel_offset r14, 8
sub sp, sp, #4 // Align the stack. sub sp, sp, #4 /* align the stack */
.cfi_adjust_cfa_offset 4 .cfi_adjust_cfa_offset 4
ldr r0, [r0, #(_JB_SIGMASK * 4)] mov r0, r2
bl sigsetmask bl PIC_SYM(sigsetmask, PLT)
add sp, sp, #4 // Unalign the stack. add sp, sp, #4 /* unalign the stack */
.cfi_adjust_cfa_offset -4 .cfi_adjust_cfa_offset -4
ldmfd sp!, {r0, r1, r14} ldmfd sp!, {r0, r1, r14}
.cfi_def_cfa_offset 0 .cfi_def_cfa_offset 0
1: #ifdef __ARM_HAVE_VFP
// Restore floating-point registers. /* Restore floating-point registers */
add r2, r0, #(_JB_FLOAT_BASE * 4) add r2, r0, #(_JB_FLOAT_BASE * 4)
vldmia r2, {d8-d15} vldmia r2, {d8-d15}
/* Restore floating-point state */
// Restore floating-point state.
ldr r2, [r0, #(_JB_FLOAT_STATE * 4)] ldr r2, [r0, #(_JB_FLOAT_STATE * 4)]
fmxr fpscr, r2 fmxr fpscr, r2
#endif /* __ARM_HAVE_VFP */
// Restore core registers. /* Restore core registers */
add r2, r0, #(_JB_CORE_BASE * 4) add r2, r0, #(_JB_CORE_BASE * 4)
ldmia r2, {r4-r14} ldmia r2, {r4-r14}
// Validate sp and r14. /* Validate sp and r14 */
teq sp, #0 teq sp, #0
teqne r14, #0 teqne r14, #0
bleq longjmperror beq botch
/* Set return value */
// Set return value.
mov r0, r1 mov r0, r1
teq r0, #0 teq r0, #0x00000000
moveq r0, #1 moveq r0, #0x00000001
bx lr bx lr
END(siglongjmp) #ifdef __ARM_26__
mov r15, r14
#else
mov r15, r14
#endif
.globl longjmp /* validation failed, die die die. */
.equ longjmp, siglongjmp botch:
.globl _longjmp bl PIC_SYM(longjmperror, PLT)
.equ _longjmp, siglongjmp bl PIC_SYM(abort, PLT)
b . - 8 /* Cannot get here */
END(longjmp)

View File

@@ -0,0 +1,66 @@
/* $OpenBSD: sigsetjmp.S,v 1.2 2004/02/01 05:40:52 drahn Exp $ */
/* $NetBSD: sigsetjmp.S,v 1.3 2002/08/17 19:54:30 thorpej Exp $ */
/*
* Copyright (c) 1997 Mark Brinicombe
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Mark Brinicombe
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#define _ALIGN_TEXT .align 0
#include <private/bionic_asm.h>
#include <machine/setjmp.h>
/*
* C library -- sigsetjmp, siglongjmp
*
* longjmp(a,v)
* will generate a "return(v)" from the last call to
* setjmp(a, m)
* by restoring registers from the stack.
* The previous signal state is restored.
*/
ENTRY(sigsetjmp)
teq r1, #0
beq PIC_SYM(_setjmp, PLT)
b PIC_SYM(setjmp, PLT)
END(sigsetjmp)
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
ENTRY(siglongjmp)
ldr r2, .L_setjmp_magic
ldr r3, [r0]
teq r2, r3
beq PIC_SYM(_longjmp, PLT)
b PIC_SYM(longjmp, PLT)
END(siglongjmp)

View File

@@ -37,7 +37,6 @@
* memset() returns its first argument. * memset() returns its first argument.
*/ */
.cpu cortex-a15
.fpu neon .fpu neon
.syntax unified .syntax unified

View File

@@ -38,7 +38,9 @@
#ifndef _ARM32_ASM_H_ #ifndef _ARM32_ASM_H_
#define _ARM32_ASM_H_ #define _ARM32_ASM_H_
#define __bionic_asm_align 0 #ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 0
#endif
#undef __bionic_asm_custom_entry #undef __bionic_asm_custom_entry
#undef __bionic_asm_custom_end #undef __bionic_asm_custom_end
@@ -48,4 +50,10 @@
#undef __bionic_asm_function_type #undef __bionic_asm_function_type
#define __bionic_asm_function_type #function #define __bionic_asm_function_type #function
#if defined(__ELF__) && defined(PIC)
#define PIC_SYM(x,y) x ## ( ## y ## )
#else
#define PIC_SYM(x,y) x
#endif
#endif /* !_ARM_ASM_H_ */ #endif /* !_ARM_ASM_H_ */

View File

@@ -28,6 +28,14 @@
#ifndef _ARM_MACHINE_CPU_FEATURES_H #ifndef _ARM_MACHINE_CPU_FEATURES_H
#define _ARM_MACHINE_CPU_FEATURES_H #define _ARM_MACHINE_CPU_FEATURES_H
/* The purpose of this file is to define several macros corresponding
* to CPU features that may or may not be available at build time on
* on the target CPU.
*
* This is done to abstract us from the various ARM Architecture
* quirks and alphabet soup.
*/
/* __ARM_ARCH__ is a number corresponding to the ARM revision /* __ARM_ARCH__ is a number corresponding to the ARM revision
* we're going to support. Our toolchain doesn't define __ARM_ARCH__ * we're going to support. Our toolchain doesn't define __ARM_ARCH__
* so try to guess it. * so try to guess it.
@@ -45,4 +53,31 @@
# endif # endif
#endif #endif
/* define __ARM_HAVE_HALFWORD_MULTIPLY when half-word multiply instructions
* this means variants of: smul, smulw, smla, smlaw, smlal
*/
#define __ARM_HAVE_HALFWORD_MULTIPLY 1
/* define __ARM_HAVE_LDREXD for ARMv7 architecture
* (also present in ARMv6K, but not implemented in ARMv7-M, neither of which
* we care about)
*/
#if __ARM_ARCH__ >= 7
# define __ARM_HAVE_LDREXD
#endif
/* define _ARM_HAVE_VFP if we have VFPv3
*/
#if __ARM_ARCH__ >= 7 && defined __VFP_FP__
# define __ARM_HAVE_VFP
#endif
/* define _ARM_HAVE_NEON for ARMv7 architecture if we support the
* Neon SIMD instruction set extensions. This also implies
* that VFPv3-D32 is supported.
*/
#if __ARM_ARCH__ >= 7 && defined __ARM_NEON__
# define __ARM_HAVE_NEON
#endif
#endif /* _ARM_MACHINE_CPU_FEATURES_H */ #endif /* _ARM_MACHINE_CPU_FEATURES_H */

View File

@@ -0,0 +1,79 @@
/* $OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $ */
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*/
#ifndef _ARM_ENDIAN_H_
#define _ARM_ENDIAN_H_
#ifdef __GNUC__
/* According to RealView Assembler User's Guide, REV and REV16 are available
* in Thumb code and 16-bit instructions when used in Thumb-2 code.
*
* REV Rd, Rm
* Rd and Rm must both be Lo registers.
*
* REV16 Rd, Rm
* Rd and Rm must both be Lo registers.
*
* The +l constraint takes care of this without constraining us in ARM mode.
*/
#define __swap16md(x) ({ \
register u_int16_t _x = (x); \
__asm__ __volatile__("rev16 %0, %0" : "+l" (_x)); \
_x; \
})
#define __swap32md(x) ({ \
register u_int32_t _x = (x); \
__asm__ __volatile__("rev %0, %0" : "+l" (_x)); \
_x; \
})
#define __swap64md(x) ({ \
u_int64_t _swap64md_x = (x); \
(u_int64_t) __swap32md(_swap64md_x >> 32) | \
(u_int64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \
})
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define MD_SWAP
#endif /* __GNUC__ */
#if defined(__ARMEB__)
#define _BYTE_ORDER _BIG_ENDIAN
#else
#define _BYTE_ORDER _LITTLE_ENDIAN
#endif
#define __STRICT_ALIGNMENT
#include <sys/types.h>
#include <sys/endian.h>
#endif /* !_ARM_ENDIAN_H_ */

View File

@@ -0,0 +1,50 @@
/* $OpenBSD: exec.h,v 1.9 2003/04/17 03:42:14 drahn Exp $ */
/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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 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.
*/
#ifndef _ARM_EXEC_H_
#define _ARM_EXEC_H_
#define __LDPGSZ 4096
#define NATIVE_EXEC_ELF
#define ARCH_ELFSIZE 32
#define ELF_TARG_CLASS ELFCLASS32
#define ELF_TARG_DATA ELFDATA2LSB
#define ELF_TARG_MACH EM_ARM
#define _NLIST_DO_AOUT
#define _NLIST_DO_ELF
#define _KERN_DO_AOUT
#define _KERN_DO_ELF
#endif /* _ARM_EXEC_H_ */

View File

@@ -26,6 +26,10 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/*
* machine/setjmp.h: machine dependent setjmp-related information.
*/
/* _JBLEN is the size of a jmp_buf in longs. /* _JBLEN is the size of a jmp_buf in longs.
* Do not modify this value or you will break the ABI ! * Do not modify this value or you will break the ABI !
* *
@@ -33,3 +37,46 @@
* that was replaced by this one. * that was replaced by this one.
*/ */
#define _JBLEN 64 #define _JBLEN 64
/* According to the ARM AAPCS document, we only need to save
* the following registers:
*
* Core r4-r14
*
* VFP d8-d15 (see section 5.1.2.1)
*
* Registers s16-s31 (d8-d15, q4-q7) must be preserved across subroutine
* calls; registers s0-s15 (d0-d7, q0-q3) do not need to be preserved
* (and can be used for passing arguments or returning results in standard
* procedure-call variants). Registers d16-d31 (q8-q15), if present, do
* not need to be preserved.
*
* FPSCR saved because GLibc does saves it too.
*
*/
/* The internal structure of a jmp_buf is totally private.
* Current layout (may change in the future):
*
* word name description
* 0 magic magic number
* 1 sigmask signal mask (not used with _setjmp / _longjmp)
* 2 float_base base of float registers (d8 to d15)
* 18 float_state floating-point status and control register
* 19 core_base base of core registers (r4 to r14)
* 30 reserved reserved entries (room to grow)
* 64
*
* NOTE: float_base must be at an even word index, since the
* FP registers will be loaded/stored with instructions
* that expect 8-byte alignment.
*/
#define _JB_MAGIC 0
#define _JB_SIGMASK (_JB_MAGIC+1)
#define _JB_FLOAT_BASE (_JB_SIGMASK+1)
#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2)
#define _JB_CORE_BASE (_JB_FLOAT_STATE+1)
#define _JB_MAGIC__SETJMP 0x4278f500
#define _JB_MAGIC_SETJMP 0x4278f501

View File

@@ -1,14 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(__rt_sigqueueinfo)
mov ip, r7
ldr r7, =__NR_rt_sigqueueinfo
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno_internal
END(__rt_sigqueueinfo)

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(__clock_nanosleep) ENTRY(clock_nanosleep)
mov ip, r7 mov ip, r7
ldr r7, =__NR_clock_nanosleep ldr r7, =__NR_clock_nanosleep
swi #0 swi #0
@@ -11,4 +11,4 @@ ENTRY(__clock_nanosleep)
bxls lr bxls lr
neg r0, r0 neg r0, r0
b __set_errno_internal b __set_errno_internal
END(__clock_nanosleep) END(clock_nanosleep)

View File

@@ -1,14 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(sethostname)
mov ip, r7
ldr r7, =__NR_sethostname
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno_internal
END(sethostname)

View File

@@ -35,8 +35,10 @@ libc_openbsd_src_files_arm64 += \
libc_bionic_src_files_arm64 += \ libc_bionic_src_files_arm64 += \
arch-arm64/bionic/__bionic_clone.S \ arch-arm64/bionic/__bionic_clone.S \
arch-arm64/bionic/_exit_with_stack_teardown.S \ arch-arm64/bionic/_exit_with_stack_teardown.S \
arch-arm64/bionic/_setjmp.S \
arch-arm64/bionic/setjmp.S \ arch-arm64/bionic/setjmp.S \
arch-arm64/bionic/__set_tls.c \ arch-arm64/bionic/__set_tls.c \
arch-arm64/bionic/sigsetjmp.S \
arch-arm64/bionic/syscall.S \ arch-arm64/bionic/syscall.S \
arch-arm64/bionic/vfork.S \ arch-arm64/bionic/vfork.S \

View File

@@ -31,8 +31,8 @@
// pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg); // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
ENTRY(__bionic_clone) ENTRY(__bionic_clone)
# Push 'fn' and 'arg' onto the child stack. # Copy 'fn' and 'arg' onto the child stack.
stp x5, x6, [x1, #-16]! stp x5, x6, [x1, #-16]
# Make the system call. # Make the system call.
mov x8, __NR_clone mov x8, __NR_clone
@@ -49,12 +49,12 @@ ENTRY(__bionic_clone)
ret ret
.L_bc_child: .L_bc_child:
# We're in the child now. Set the end of the frame record chain. # We're in the child now. Set the end of the frame record chain...
mov x29, #0 mov x29, xzr
# Setting x30 to 0 will make the unwinder stop at __start_thread. # Setting x30 to 0 will make the unwinder stop at __start_thread
mov x30, #0 mov x30, xzr
# Call __start_thread with the 'fn' and 'arg' we stored on the child stack. # ...and call __start_thread with the 'fn' and 'arg' we stored on the child stack.
ldp x0, x1, [sp], #16 ldp x0, x1, [sp, #-16]
b __start_thread b __start_thread
END(__bionic_clone) END(__bionic_clone)
.hidden __bionic_clone .hidden __bionic_clone

View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*/
#include <private/bionic_asm.h>
#include <machine/setjmp.h>
/*
* C library - _setjmp, _longjmp
*
* _longjmp(jmp_buf state, int value)
* will generate a "return(v)" from the last call to _setjmp(state) by restoring
* registers from the stack. The previous signal state is NOT restored.
*
* NOTE: x0 return value
* x9-x15 temporary registers
*/
ENTRY(_setjmp)
/* store magic number */
ldr w9, .L_setjmp_magic
str w9, [x0, #(_JB_MAGIC * 4)]
/* store core registers */
mov x10, sp
stp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
stp x28, x29, [x0, #(_JB_CORE_BASE * 4 + 16 * 1)]
stp x26, x27, [x0, #(_JB_CORE_BASE * 4 + 16 * 2)]
stp x24, x25, [x0, #(_JB_CORE_BASE * 4 + 16 * 3)]
stp x22, x23, [x0, #(_JB_CORE_BASE * 4 + 16 * 4)]
stp x20, x21, [x0, #(_JB_CORE_BASE * 4 + 16 * 5)]
str x19, [x0, #(_JB_CORE_BASE * 4 + 16 * 6)]
/* store floating point registers */
stp d14, d15, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 0)]
stp d12, d13, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 1)]
stp d10, d11, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 2)]
stp d8, d9, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 3)]
mov w0, wzr
ret
END(_setjmp)
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
ENTRY(_longjmp)
/* check magic */
ldr w9, .L_setjmp_magic
ldr w10, [x0, #(_JB_MAGIC * 4)]
cmp w9, w10
b.ne .L_fail
/* restore core registers */
ldp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
mov sp, x10
ldp x28, x29, [x0, #(_JB_CORE_BASE * 4 + 16 * 1)]
ldp x26, x27, [x0, #(_JB_CORE_BASE * 4 + 16 * 2)]
ldp x24, x25, [x0, #(_JB_CORE_BASE * 4 + 16 * 3)]
ldp x22, x23, [x0, #(_JB_CORE_BASE * 4 + 16 * 4)]
ldp x20, x21, [x0, #(_JB_CORE_BASE * 4 + 16 * 5)]
ldr x19, [x0, #(_JB_CORE_BASE * 4 + 16 * 6)]
/* restore floating point registers */
ldp d14, d15, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 0)]
ldp d12, d13, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 1)]
ldp d10, d11, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 2)]
ldp d8, d9, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 3)]
/* validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0) */
tst x30, #3
b.ne .L_fail
mov x10, sp
tst x10, #15
b.ne .L_fail
/* set return value */
cmp w1, wzr
csinc w0, w1, wzr, ne
ret
/* validation failed, die die die */
.L_fail:
bl PIC_SYM(longjmperror, PLT)
bl PIC_SYM(abort, PLT)
b . - 8 /* Cannot get here */
END(_longjmp)

View File

@@ -27,126 +27,97 @@
*/ */
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
#include <machine/setjmp.h>
// According to AARCH64 PCS document we need to save the following /*
// registers: * C library - _setjmp, _longjmp
// *
// Core x19 - x30, sp (see section 5.1.1) * _longjmp(jmp_buf state, int value)
// VFP d8 - d15 (see section 5.1.2) * will generate a "return(v)" from the last call to _setjmp(state) by restoring
// * registers from the stack. The previous signal state is NOT restored.
// NOTE: All the registers saved here will have 64 bit vales. *
// AAPCS mandates that the higher part of q registers do not need to * NOTE: x0 return value
// be saved by the callee. * x9-x15 temporary registers
*/
#define _JB_SIGFLAG 0
#define _JB_SIGMASK (_JB_SIGFLAG + 1)
#define _JB_X30_SP (_JB_SIGMASK + 1)
#define _JB_X28_X29 (_JB_X30_SP + 2)
#define _JB_X26_X27 (_JB_X28_X29 + 2)
#define _JB_X24_X25 (_JB_X26_X27 + 2)
#define _JB_X22_X23 (_JB_X24_X25 + 2)
#define _JB_X20_X21 (_JB_X22_X23 + 2)
#define _JB_X19 (_JB_X20_X21 + 2)
#define _JB_D14_D15 (_JB_X19 + 1)
#define _JB_D12_D13 (_JB_D14_D15 + 2)
#define _JB_D10_D11 (_JB_D12_D13 + 1)
#define _JB_D8_D9 (_JB_D10_D11 + 1)
ENTRY(setjmp) ENTRY(setjmp)
mov w1, #1 /* block all signals an retrieve signal mask */
b sigsetjmp stp x0, x30, [sp, #-16]!
mov x0, xzr
bl PIC_SYM(sigblock, PLT)
mov w1, w0
ldp x0, x30, [sp], #16
/* store signal mask */
str w1, [x0, #(_JB_SIGMASK *4)]
/* store magic number */
ldr w9, .L_setjmp_magic
str w9, [x0, #(_JB_MAGIC * 4)]
/* store core registers */
mov x10, sp
stp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
stp x28, x29, [x0, #(_JB_CORE_BASE * 4 + 16 * 1)]
stp x26, x27, [x0, #(_JB_CORE_BASE * 4 + 16 * 2)]
stp x24, x25, [x0, #(_JB_CORE_BASE * 4 + 16 * 3)]
stp x22, x23, [x0, #(_JB_CORE_BASE * 4 + 16 * 4)]
stp x20, x21, [x0, #(_JB_CORE_BASE * 4 + 16 * 5)]
str x19, [x0, #(_JB_CORE_BASE * 4 + 16 * 6)]
/* store floating point registers */
stp d14, d15, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 0)]
stp d12, d13, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 1)]
stp d10, d11, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 2)]
stp d8, d9, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 3)]
mov w0, wzr
ret
END(setjmp) END(setjmp)
ENTRY(_setjmp) .L_setjmp_magic:
mov w1, #0 .word _JB_MAGIC__SETJMP
b sigsetjmp
END(_setjmp)
// int sigsetjmp(sigjmp_buf env, int save_signal_mask); ENTRY(longjmp)
ENTRY(sigsetjmp) /* check magic */
// Record whether or not we're saving the signal mask. ldr w9, .L_setjmp_magic
str w1, [x0, #(_JB_SIGFLAG * 8)] ldr w10, [x0, #(_JB_MAGIC * 4)]
cmp w9, w10
b.ne .L_fail
// Do we need to save the signal mask? /* restore core registers */
cbz w1, 1f ldp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
// Save current signal mask.
stp x0, x30, [sp, #-16]!
// The 'how' argument is ignored if new_mask is NULL.
mov x1, #0 // NULL.
add x2, x0, #(_JB_SIGMASK * 8) // old_mask.
bl sigprocmask
ldp x0, x30, [sp], #16
1:
// Save core registers.
mov x10, sp
stp x30, x10, [x0, #(_JB_X30_SP * 8)]
stp x28, x29, [x0, #(_JB_X28_X29 * 8)]
stp x26, x27, [x0, #(_JB_X26_X27 * 8)]
stp x24, x25, [x0, #(_JB_X24_X25 * 8)]
stp x22, x23, [x0, #(_JB_X22_X23 * 8)]
stp x20, x21, [x0, #(_JB_X20_X21 * 8)]
str x19, [x0, #(_JB_X19 * 8)]
// Save floating point registers.
stp d14, d15, [x0, #(_JB_D14_D15 * 8)]
stp d12, d13, [x0, #(_JB_D12_D13 * 8)]
stp d10, d11, [x0, #(_JB_D10_D11 * 8)]
stp d8, d9, [x0, #(_JB_D8_D9 * 8)]
mov w0, #0
ret
END(sigsetjmp)
// void siglongjmp(sigjmp_buf env, int value);
ENTRY(siglongjmp)
// Do we need to restore the signal mask?
ldr w9, [x0, #(_JB_SIGFLAG * 8)]
cbz w9, 1f
// Restore signal mask.
stp x0, x30, [sp, #-16]!
mov x19, x1 // Save 'value'.
mov x2, x0
mov x0, #2 // SIG_SETMASK
add x1, x2, #(_JB_SIGMASK * 8) // new_mask.
mov x2, #0 // NULL.
bl sigprocmask
mov x1, x19 // Restore 'value'.
ldp x0, x30, [sp], #16
1:
// Restore core registers.
ldp x30, x10, [x0, #(_JB_X30_SP * 8)]
mov sp, x10 mov sp, x10
ldp x28, x29, [x0, #(_JB_X28_X29 * 8)] ldp x28, x29, [x0, #(_JB_CORE_BASE * 4 + 16 * 1)]
ldp x26, x27, [x0, #(_JB_X26_X27 * 8)] ldp x26, x27, [x0, #(_JB_CORE_BASE * 4 + 16 * 2)]
ldp x24, x25, [x0, #(_JB_X24_X25 * 8)] ldp x24, x25, [x0, #(_JB_CORE_BASE * 4 + 16 * 3)]
ldp x22, x23, [x0, #(_JB_X22_X23 * 8)] ldp x22, x23, [x0, #(_JB_CORE_BASE * 4 + 16 * 4)]
ldp x20, x21, [x0, #(_JB_X20_X21 * 8)] ldp x20, x21, [x0, #(_JB_CORE_BASE * 4 + 16 * 5)]
ldr x19, [x0, #(_JB_X19 * 8)] ldr x19, [x0, #(_JB_CORE_BASE * 4 + 16 * 6)]
// Restore floating point registers. /* restore floating point registers */
ldp d14, d15, [x0, #(_JB_D14_D15 * 8)] ldp d14, d15, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 0)]
ldp d12, d13, [x0, #(_JB_D12_D13 * 8)] ldp d12, d13, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 1)]
ldp d10, d11, [x0, #(_JB_D10_D11 * 8)] ldp d10, d11, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 2)]
ldp d8, d9, [x0, #(_JB_D8_D9 * 8)] ldp d8, d9, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 3)]
// Validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0). /* validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0) */
tst x30, #3 tst x30, #3
b.ne longjmperror b.ne .L_fail
mov x10, sp mov x10, sp
tst x10, #15 tst x10, #15
b.ne longjmperror b.ne .L_fail
// Set return value. /* set return value */
cmp w1, wzr cmp w1, wzr
csinc w0, w1, wzr, ne csinc w0, w1, wzr, ne
ret ret
END(siglongjmp)
.globl longjmp /* validation failed, die die die */
.equ longjmp, siglongjmp .L_fail:
.globl _longjmp bl PIC_SYM(longjmperror, PLT)
.equ _longjmp, siglongjmp bl PIC_SYM(abort, PLT)
b . - 8 /* Cannot get here */
END(longjmp)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2014 The Android Open Source Project * Copyright (C) 2013 The Android Open Source Project
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -26,21 +26,26 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef _MACHINE_TIMESPEC_H_ #include <private/bionic_asm.h>
#define _MACHINE_TIMESPEC_H_ #include <machine/setjmp.h>
#include <sys/types.h>
/* /*
* This file is used to include timespec definition without introducing the whole * int sigsetjmp(sigjmp_buf env, int savesigs);
* <linux/time.h>, <sys/time.h> or <time.h>. * void siglongjmp(sigjmp_buf env, int val);
*/ */
#ifndef _STRUCT_TIMESPEC
#define _STRUCT_TIMESPEC
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif
#endif /* _MACHINE_TIMESPEC_H_ */ ENTRY(sigsetjmp)
cbz w1, PIC_SYM(_setjmp, PLT)
b PIC_SYM(setjmp, PLT)
END(sigsetjmp)
.L_setjmp_magic:
.word _JB_MAGIC__SETJMP
ENTRY(siglongjmp)
ldr w2, .L_setjmp_magic
ldr w3, [x0]
cmp w2, w3
b.eq PIC_SYM(_longjmp, PLT)
b PIC_SYM(longjmp, PLT)
END(siglongjmp)

View File

@@ -38,9 +38,17 @@
#ifndef _AARCH64_ASM_H_ #ifndef _AARCH64_ASM_H_
#define _AARCH64_ASM_H_ #define _AARCH64_ASM_H_
#define __bionic_asm_align 0 #ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 0
#endif
#undef __bionic_asm_function_type #undef __bionic_asm_function_type
#define __bionic_asm_function_type %function #define __bionic_asm_function_type %function
#if defined(__ELF__) && defined(PIC)
#define PIC_SYM(x,y) x ## ( ## y ## )
#else
#define PIC_SYM(x,y) x
#endif
#endif /* _AARCH64_ASM_H_ */ #endif /* _AARCH64_ASM_H_ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2014 The Android Open Source Project * Copyright (C) 2013 The Android Open Source Project
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -26,21 +26,33 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <signal.h> #ifndef _AARCH64_ENDIAN_H_
#include <string.h> #define _AARCH64_ENDIAN_H_
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <sys/endian.h>
extern "C" int __rt_sigqueueinfo(pid_t, int, siginfo_t*); #ifdef __GNUC__
int sigqueue(pid_t pid, int signo, const sigval value) { #define __swap16md(x) ({ \
siginfo_t info; register u_int16_t _x = (x); \
memset(&info, 0, sizeof(siginfo_t)); __asm volatile ("rev16 %0, %0" : "+r" (_x)); \
info.si_signo = signo; _x; \
info.si_code = SI_QUEUE; })
info.si_pid = getpid();
info.si_uid = getuid();
info.si_value = value;
return __rt_sigqueueinfo(pid, signo, &info); /* Use GCC builtins */
} #define __swap32md(x) __builtin_bswap32(x)
#define __swap64md(x) __builtin_bswap64(x)
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define MD_SWAP
#endif /* __GNUC__ */
#if defined(__AARCH64EB__)
#define _BYTE_ORDER _BIG_ENDIAN
#else
#define _BYTE_ORDER _LITTLE_ENDIAN
#endif
#endif /* _AARCH64_ENDIAN_H_ */

View File

@@ -0,0 +1,50 @@
/* $OpenBSD: exec.h,v 1.9 2003/04/17 03:42:14 drahn Exp $ */
/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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 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.
*/
#ifndef _AARCH64_EXEC_H_
#define _AARCH64_EXEC_H_
#define __LDPGSZ 4096
#define NATIVE_EXEC_ELF
#define ARCH_ELFSIZE 64
#define ELF_TARG_CLASS ELFCLASS64 /* 64-bit objects */
#define ELF_TARG_DATA ELFDATA2LSB
#define ELF_TARG_MACH EM_AARCH64
#define _NLIST_DO_AOUT
#define _NLIST_DO_ELF
#define _KERN_DO_AOUT
#define _KERN_DO_ELF64
#endif /* _AARCH64_EXEC_H_ */

View File

@@ -26,5 +26,48 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/* _JBLEN is the size of a jmp_buf in longs (64bit on AArch64) */ /*
* machine/setjmp.h: machine dependent setjmp-related information.
*/
/* _JBLEN is the size of a jmp_buf in longs(64bit on AArch64) */
#define _JBLEN 32 #define _JBLEN 32
/* According to AARCH64 PCS document we need to save the following
* registers:
*
* Core x19 - x30, sp (see section 5.1.1)
* VFP d8 - d15 (see section 5.1.2)
*
* NOTE: All the registers saved here will have 64bit vales (except FPSR).
* AAPCS mandates that the higher part of q registers does not need to
* be saveved by the callee.
*/
/* The structure of jmp_buf for AArch64:
*
* NOTE: _JBLEN is the size of jmp_buf in longs(64bit on AArch64)! The table
* below computes the offsets in words(32bit).
*
* word name description
* 0 magic magic number
* 1 sigmask signal mask (not used with _setjmp / _longjmp)
* 2 core_base base of core registers (x19-x30, sp)
* 28 float_base base of float registers (d8-d15)
* 44 reserved reserved entries (room to grow)
* 64
*
*
* NOTE: The instructions that load/store core/vfp registers expect 8-byte
* alignment. Contrary to the previous setjmp header for ARM we do not
* need to save status/control registers for VFP (it is not a
* requirement for setjmp).
*/
#define _JB_MAGIC 0
#define _JB_SIGMASK (_JB_MAGIC+1)
#define _JB_CORE_BASE (_JB_SIGMASK+1)
#define _JB_FLOAT_BASE (_JB_CORE_BASE + (31-19+1)*2)
#define _JB_MAGIC__SETJMP 0x53657200
#define _JB_MAGIC_SETJMP 0x53657201

View File

@@ -1,15 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(__rt_sigqueueinfo)
mov x8, __NR_rt_sigqueueinfo
svc #0
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno_internal
ret
END(__rt_sigqueueinfo)
.hidden __rt_sigqueueinfo

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(__clock_nanosleep) ENTRY(clock_nanosleep)
mov x8, __NR_clock_nanosleep mov x8, __NR_clock_nanosleep
svc #0 svc #0
@@ -11,5 +11,4 @@ ENTRY(__clock_nanosleep)
b.hi __set_errno_internal b.hi __set_errno_internal
ret ret
END(__clock_nanosleep) END(clock_nanosleep)
.hidden __clock_nanosleep

View File

@@ -1,14 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(sethostname)
mov x8, __NR_sethostname
svc #0
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno_internal
ret
END(sethostname)

View File

@@ -0,0 +1,150 @@
/* $OpenBSD: _setjmp.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
/*
* Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of Opsycon AB nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*
*/
#include <private/bionic_asm.h>
#include <machine/regnum.h>
#include <machine/signal.h>
/*
* _setjmp, _longjmp (not restoring signal state)
*
* XXX FPSET should probably be taken from SR setting. hmmm...
* GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
*
*/
FRAMESZ= MKFSIZ(0,4)
GPOFF= FRAMESZ-2*REGSZ
LEAF(_setjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _setjmp)
SAVE_GP(GPOFF)
.set noreorder
#if defined(__mips64)
dli v0, 0xACEDBADE # sigcontext magic number
#else
li v0, 0xACEDBADE # sigcontext magic number
#endif
REG_S v0, SC_REGS+ZERO*REGSZ(a0)
REG_S s0, SC_REGS+S0*REGSZ(a0)
REG_S s1, SC_REGS+S1*REGSZ(a0)
REG_S s2, SC_REGS+S2*REGSZ(a0)
REG_S s3, SC_REGS+S3*REGSZ(a0)
REG_S s4, SC_REGS+S4*REGSZ(a0)
REG_S s5, SC_REGS+S5*REGSZ(a0)
REG_S s6, SC_REGS+S6*REGSZ(a0)
REG_S s7, SC_REGS+S7*REGSZ(a0)
REG_S s8, SC_REGS+S8*REGSZ(a0)
REG_L v0, GPOFF(sp)
REG_S v0, SC_REGS+GP*REGSZ(a0)
PTR_ADDU v0, sp, FRAMESZ
REG_S v0, SC_REGS+SP*REGSZ(a0)
REG_S ra, SC_PC(a0)
#if !defined(SOFTFLOAT)
li v0, 1 # be nice if we could tell
REG_S v0, SC_FPUSED(a0) # sc_fpused = 1
cfc1 v0, $31
s.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
s.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
s.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
s.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
s.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
s.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
s.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
s.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
s.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
s.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
s.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
s.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
REG_S v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
#endif /* !SOFTFLOAT */
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
j ra
move v0, zero
END(_setjmp)
LEAF(_longjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _longjmp)
SAVE_GP(GPOFF)
.set noreorder
REG_L v0, SC_REGS+ZERO*REGSZ(a0)
bne v0, 0xACEDBADE, botch # jump if error
REG_L ra, SC_PC(a0)
REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
REG_L s0, SC_REGS+S0*REGSZ(a0)
REG_L s1, SC_REGS+S1*REGSZ(a0)
REG_L s2, SC_REGS+S2*REGSZ(a0)
REG_L s3, SC_REGS+S3*REGSZ(a0)
REG_L s4, SC_REGS+S4*REGSZ(a0)
REG_L s5, SC_REGS+S5*REGSZ(a0)
REG_L s6, SC_REGS+S6*REGSZ(a0)
REG_L s7, SC_REGS+S7*REGSZ(a0)
REG_L s8, SC_REGS+S8*REGSZ(a0)
REG_L gp, SC_REGS+GP*REGSZ(a0)
REG_L sp, SC_REGS+SP*REGSZ(a0)
#if !defined(SOFTFLOAT)
ctc1 v0, $31
l.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
l.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
l.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
l.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
l.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
l.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
l.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
l.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
l.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
l.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
l.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
l.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
#endif /* !SOFTFLOAT */
bne a1, zero, 1f
nop
li a1, 1 # never return 0!
1:
j ra
move v0, a1
botch:
jal longjmperror
nop
jal abort
nop
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
END(_longjmp)

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*/
extern void *__dso_handle;
extern int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
__attribute__ ((visibility ("hidden")))
int atexit(void (*func)(void))
{
return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
}

View File

@@ -91,4 +91,4 @@ __asm__ (
); );
#include "../../arch-common/bionic/__dso_handle.h" #include "../../arch-common/bionic/__dso_handle.h"
#include "../../arch-common/bionic/atexit.h" #include "atexit.h"

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*/
extern void __cxa_finalize(void *);
extern void *__dso_handle;
__attribute__((visibility("hidden"),destructor))
void __on_dlclose() {
__cxa_finalize(&__dso_handle);
}
#include "../../arch-common/bionic/__dso_handle_so.h"
#include "atexit.h"

View File

@@ -1,3 +1,5 @@
/* $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
/* /*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
* *
@@ -26,116 +28,14 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
/*-
* Copyright (c) 1991, 1993, 1995,
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Havard Eidnes.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)signal.h 8.1 (Berkeley) 6/10/93
*/
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
#include <machine/setjmp.h> #include <machine/regnum.h>
#include <machine/signal.h>
/* On Mips32, jmpbuf begins with optional 4-byte filler so that
* all saved FP regs are aligned on 8-byte boundary, despite this whole
* struct being mis-declared to users as an array of (4-byte) longs.
* All the following offsets are then from the rounded-up base addr
*/
/* Fields of same size on all MIPS abis: */
#define SC_MAGIC (0*4) /* 4 bytes, identify jmpbuf */
#define SC_MASK (1*4) /* 4 bytes, saved signal mask */
#define SC_FPSR (2*4) /* 4 bytes, floating point control/status reg */
/* filler2 (3*4) 4 bytes, pad to 8-byte boundary */
/* Registers that are 4-byte on mips32 o32, and 8-byte on mips64 n64 abi */
#define SC_REGS_SAVED 12 /* ra,gp,sp,s0-s8 */
#define SC_REGS (4*4) /* SC_REGS_SAVED*REGSZ bytes */
/* Floating pt registers are 8-bytes on all abis,
* but the number of saved fp regs varies for o32/n32 versus n64 abis:
*/
#ifdef __LP64__
#define SC_FPREGS_SAVED 8 /* all fp regs f24,f25,f26,f27,f28,f29,f30,f31 */
#else
#define SC_FPREGS_SAVED 6 /* even fp regs f20,f22,f24,f26,f28,f30 */
#endif
#define SC_FPREGS (SC_REGS + SC_REGS_SAVED*REGSZ) /* SC_FPREGS_SAVED*REGSZ_FP bytes */
#define SC_BYTES (SC_FPREGS + SC_FPREGS_SAVED*REGSZ_FP)
#define SC_LONGS (SC_BYTES/REGSZ)
#ifdef __LP64__
/* SC_LONGS is 22, so _JBLEN should be 22 or larger */
#else
/* SC_LONGS is 28, but must also allocate dynamic-roundup filler.
so _JBLEN should be 29 or larger */
#endif
/* /*
* _setjmp, _longjmp (restoring signal state) * setjmp, longjmp implementation for libc. this code depends
* * on the layout of the struct sigcontext in machine/signal.h.
* GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
* *
*/ */
@@ -151,319 +51,124 @@ NON_LEAF(setjmp, FRAMESZ, ra)
SETUP_GP64(GPOFF, setjmp) SETUP_GP64(GPOFF, setjmp)
SAVE_GP(GPOFF) SAVE_GP(GPOFF)
.set reorder .set reorder
#ifndef __LP64__
addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
li t0, ~7
and a0, t0
#endif
REG_S ra, RAOFF(sp) # save state REG_S ra, RAOFF(sp) # save state
REG_S a0, A0OFF(sp) REG_S a0, A0OFF(sp)
move a0, zero # get current signal mask move a0, zero # get current signal mask
jal sigblock jal sigblock
REG_L a0, A0OFF(sp)
REG_L v1, A0OFF(sp) # v1 = jmpbuf
REG_S v0, SC_MASK(v1) # save sc_mask = sigblock(0)
REG_L a0, A0OFF(sp) # restore jmpbuf
REG_L ra, RAOFF(sp) REG_L ra, RAOFF(sp)
REG_S ra, SC_PC(a0) # sc_pc = return address
REG_S v0, SC_MASK(a0) # save sc_mask = sigblock(0) #if defined(__mips64)
dli v0, 0xACEDBADE # sigcontext magic number
li v0, 0xACEDBADE # sigcontext magic number
sw v0, SC_MAGIC(a0)
# callee-saved long-sized regs:
REG_S ra, SC_REGS+0*REGSZ(a0)
REG_S s0, SC_REGS+1*REGSZ(a0)
REG_S s1, SC_REGS+2*REGSZ(a0)
REG_S s2, SC_REGS+3*REGSZ(a0)
REG_S s3, SC_REGS+4*REGSZ(a0)
REG_S s4, SC_REGS+5*REGSZ(a0)
REG_S s5, SC_REGS+6*REGSZ(a0)
REG_S s6, SC_REGS+7*REGSZ(a0)
REG_S s7, SC_REGS+8*REGSZ(a0)
REG_S s8, SC_REGS+9*REGSZ(a0)
REG_L v0, GPOFF(sp)
REG_S v0, SC_REGS+10*REGSZ(a0)
PTR_ADDU v0, sp, FRAMESZ
REG_S v0, SC_REGS+11*REGSZ(a0)
cfc1 v0, $31
#ifdef __LP64__
# callee-saved fp regs on mips n64 ABI are $f24..$f31
s.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
s.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
s.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
s.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
s.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
s.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
s.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
#else #else
# callee-saved fp regs on mips o32 ABI are li v0, 0xACEDBADE # sigcontext magic number
# the even-numbered fp regs $f20,$f22,...$f30
s.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
s.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
s.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
s.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
s.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
#endif #endif
sw v0, SC_FPSR(a0) REG_S v0, SC_REGS+ZERO*REGSZ(a0)
REG_S s0, SC_REGS+S0*REGSZ(a0)
REG_S s1, SC_REGS+S1*REGSZ(a0)
REG_S s2, SC_REGS+S2*REGSZ(a0)
REG_S s3, SC_REGS+S3*REGSZ(a0)
REG_S s4, SC_REGS+S4*REGSZ(a0)
REG_S s5, SC_REGS+S5*REGSZ(a0)
REG_S s6, SC_REGS+S6*REGSZ(a0)
REG_S s7, SC_REGS+S7*REGSZ(a0)
REG_S s8, SC_REGS+S8*REGSZ(a0)
REG_L v0, GPOFF(sp)
REG_S v0, SC_REGS+GP*REGSZ(a0)
PTR_ADDU v0, sp, FRAMESZ
REG_S v0, SC_REGS+SP*REGSZ(a0)
#if !defined(SOFTFLOAT)
li v0, 1 # be nice if we could tell
REG_S v0, SC_FPUSED(a0) # sc_fpused = 1
cfc1 v0, $31
s.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
s.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
s.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
s.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
s.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
s.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
s.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
s.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
s.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
s.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
s.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
s.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
REG_S v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
#endif /* !SOFTFLOAT */
move v0, zero move v0, zero
RESTORE_GP64 RESTORE_GP64
PTR_ADDU sp, FRAMESZ PTR_ADDU sp, FRAMESZ
j ra j ra
botch:
jal longjmperror
jal abort
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
END(setjmp) END(setjmp)
NON_LEAF(longjmp, FRAMESZ, ra)
.mask 0x80000000, RAOFF LEAF(longjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, longjmp) SETUP_GP64(GPOFF, longjmp)
SAVE_GP(GPOFF) SAVE_GP(GPOFF)
.set reorder .set reorder
sw a1, A1OFF(sp)
sw a0, A0OFF(sp)
#ifndef __LP64__
addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
li t0, ~7
and a0, t0
#endif
REG_S a1, A1OFF(sp)
REG_S a0, A0OFF(sp)
lw a0, SC_MASK(a0) lw a0, SC_MASK(a0)
jal sigsetmask jal sigsetmask
REG_L a0, A0OFF(sp)
REG_L a1, A1OFF(sp)
lw v0, SC_MAGIC(a0) lw a0, A0OFF(sp)
li t0, 0xACEDBADE lw a1, A1OFF(sp)
bne v0, t0, longjmp_botch # jump if error
# callee-saved long-sized regs: .set noreorder
REG_L ra, SC_REGS+0*REGSZ(a0) REG_L v0, SC_REGS+ZERO*REGSZ(a0)
REG_L s0, SC_REGS+1*REGSZ(a0) bne v0, 0xACEDBADE, botch # jump if error
REG_L s1, SC_REGS+2*REGSZ(a0) REG_L ra, SC_PC(a0)
REG_L s2, SC_REGS+3*REGSZ(a0) REG_L s0, SC_REGS+S0*REGSZ(a0)
REG_L s3, SC_REGS+4*REGSZ(a0) REG_L s1, SC_REGS+S1*REGSZ(a0)
REG_L s4, SC_REGS+5*REGSZ(a0) REG_L s2, SC_REGS+S2*REGSZ(a0)
REG_L s5, SC_REGS+6*REGSZ(a0) REG_L s3, SC_REGS+S3*REGSZ(a0)
REG_L s6, SC_REGS+7*REGSZ(a0) REG_L s4, SC_REGS+S4*REGSZ(a0)
REG_L s7, SC_REGS+8*REGSZ(a0) REG_L s5, SC_REGS+S5*REGSZ(a0)
REG_L s8, SC_REGS+9*REGSZ(a0) REG_L s6, SC_REGS+S6*REGSZ(a0)
REG_L gp, SC_REGS+10*REGSZ(a0) REG_L s7, SC_REGS+S7*REGSZ(a0)
REG_L sp, SC_REGS+11*REGSZ(a0) REG_L s8, SC_REGS+S8*REGSZ(a0)
REG_L gp, SC_REGS+GP*REGSZ(a0)
REG_L sp, SC_REGS+SP*REGSZ(a0)
lw v0, SC_FPSR(a0) #if !defined(SOFTFLOAT)
REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
ctc1 v0, $31 ctc1 v0, $31
#ifdef __LP64__ l.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
# callee-saved fp regs on mips n64 ABI are $f24..$f31 l.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
l.d $f24, SC_FPREGS+0*REGSZ_FP(a0) l.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
l.d $f25, SC_FPREGS+1*REGSZ_FP(a0) l.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
l.d $f26, SC_FPREGS+2*REGSZ_FP(a0) l.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
l.d $f27, SC_FPREGS+3*REGSZ_FP(a0) l.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
l.d $f28, SC_FPREGS+4*REGSZ_FP(a0) #if _MIPS_FPSET == 32
l.d $f29, SC_FPREGS+5*REGSZ_FP(a0) l.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
l.d $f30, SC_FPREGS+6*REGSZ_FP(a0) l.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
l.d $f31, SC_FPREGS+7*REGSZ_FP(a0) l.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
#else l.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
# callee-saved fp regs on mips o32 ABI are l.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
# the even-numbered fp regs $f20,$f22,...$f30 l.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
l.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
l.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
l.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
l.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
l.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
#endif #endif
#endif /* !SOFTFLOAT */
bne a1, zero, 1f bne a1, zero, 1f
nop
li a1, 1 # never return 0! li a1, 1 # never return 0!
1: 1:
move v0, a1
j ra j ra
move v0, a1
longjmp_botch:
jal longjmperror
jal abort
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
END(longjmp) END(longjmp)
/*
* _setjmp, _longjmp (not restoring signal state)
*
* GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
*
*/
FRAMESZ= MKFSIZ(0,4)
GPOFF= FRAMESZ-2*REGSZ
LEAF(_setjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _setjmp)
SAVE_GP(GPOFF)
.set reorder
#ifndef __LP64__
addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
li t0, ~7
and a0, t0
#endif
# SC_MASK is unused here
li v0, 0xACEDBADE # sigcontext magic number
sw v0, SC_MAGIC(a0)
# callee-saved long-sized regs:
REG_S ra, SC_REGS+0*REGSZ(a0)
REG_S s0, SC_REGS+1*REGSZ(a0)
REG_S s1, SC_REGS+2*REGSZ(a0)
REG_S s2, SC_REGS+3*REGSZ(a0)
REG_S s3, SC_REGS+4*REGSZ(a0)
REG_S s4, SC_REGS+5*REGSZ(a0)
REG_S s5, SC_REGS+6*REGSZ(a0)
REG_S s6, SC_REGS+7*REGSZ(a0)
REG_S s7, SC_REGS+8*REGSZ(a0)
REG_S s8, SC_REGS+9*REGSZ(a0)
REG_L v0, GPOFF(sp)
REG_S v0, SC_REGS+10*REGSZ(a0)
PTR_ADDU v0, sp, FRAMESZ
REG_S v0, SC_REGS+11*REGSZ(a0)
cfc1 v0, $31
#ifdef __LP64__
# callee-saved fp regs on mips n64 ABI are $f24..$f31
s.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
s.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
s.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
s.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
s.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
s.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
s.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
#else
# callee-saved fp regs on mips o32 ABI are
# the even-numbered fp regs $f20,$f22,...$f30
s.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
s.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
s.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
s.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
s.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
s.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
#endif
sw v0, SC_FPSR(a0)
move v0, zero
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
j ra
END(_setjmp)
LEAF(_longjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _longjmp)
SAVE_GP(GPOFF)
.set reorder
#ifndef __LP64__
addiu a0, 7 # roundup jmpbuf addr to 8-byte boundary
li t0, ~7
and a0, t0
#endif
# SC_MASK is unused here
lw v0, SC_MAGIC(a0)
li t0, 0xACEDBADE
bne v0, t0, _longjmp_botch # jump if error
# callee-saved long-sized regs:
REG_L ra, SC_REGS+0*REGSZ(a0)
REG_L s0, SC_REGS+1*REGSZ(a0)
REG_L s1, SC_REGS+2*REGSZ(a0)
REG_L s2, SC_REGS+3*REGSZ(a0)
REG_L s3, SC_REGS+4*REGSZ(a0)
REG_L s4, SC_REGS+5*REGSZ(a0)
REG_L s5, SC_REGS+6*REGSZ(a0)
REG_L s6, SC_REGS+7*REGSZ(a0)
REG_L s7, SC_REGS+8*REGSZ(a0)
REG_L s8, SC_REGS+9*REGSZ(a0)
REG_L gp, SC_REGS+10*REGSZ(a0)
REG_L sp, SC_REGS+11*REGSZ(a0)
lw v0, SC_FPSR(a0)
ctc1 v0, $31
#ifdef __LP64__
# callee-saved fp regs on mips n64 ABI are $f24..$f31
l.d $f24, SC_FPREGS+0*REGSZ_FP(a0)
l.d $f25, SC_FPREGS+1*REGSZ_FP(a0)
l.d $f26, SC_FPREGS+2*REGSZ_FP(a0)
l.d $f27, SC_FPREGS+3*REGSZ_FP(a0)
l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
l.d $f29, SC_FPREGS+5*REGSZ_FP(a0)
l.d $f30, SC_FPREGS+6*REGSZ_FP(a0)
l.d $f31, SC_FPREGS+7*REGSZ_FP(a0)
#else
# callee-saved fp regs on mips o32 ABI are
# the even-numbered fp regs $f20,$f22,...$f30
l.d $f20, SC_FPREGS+0*REGSZ_FP(a0)
l.d $f22, SC_FPREGS+1*REGSZ_FP(a0)
l.d $f24, SC_FPREGS+2*REGSZ_FP(a0)
l.d $f26, SC_FPREGS+3*REGSZ_FP(a0)
l.d $f28, SC_FPREGS+4*REGSZ_FP(a0)
l.d $f30, SC_FPREGS+5*REGSZ_FP(a0)
#endif
bne a1, zero, 1f
li a1, 1 # never return 0!
1:
move v0, a1
j ra
_longjmp_botch:
jal longjmperror
jal abort
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
END(_longjmp)
/*
* trampolines for sigsetjmp and siglongjmp save and restore mask.
*
*/
FRAMESZ= MKFSIZ(1,1)
GPOFF= FRAMESZ-2*REGSZ
LEAF(sigsetjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, sigsetjmp)
.set reorder
sw a1, _JBLEN*REGSZ(a0) # save "savemask"
bne a1, 0x0, 1f # do saving of signal mask?
LA t9, _setjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
1: LA t9, setjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
END(sigsetjmp)
LEAF(siglongjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, siglongjmp)
.set reorder
lw t0, _JBLEN*REGSZ(a0) # get "savemask"
bne t0, 0x0, 1f # restore signal mask?
LA t9, _longjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
1:
LA t9, longjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
END(siglongjmp)

View File

@@ -1,8 +1,11 @@
/* $OpenBSD: vwarnx.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ /* $OpenBSD: sigsetjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1991, 1993, 1995,
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* This code is derived from software contributed to Berkeley by
* Havard Eidnes.
*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@@ -28,20 +31,47 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <err.h> #include <private/bionic_asm.h>
#include <stdio.h> #include <machine/regnum.h>
#include <stdarg.h> #include <machine/setjmp.h>
extern char *__progname; /* Program name, from crt0. */ /*
* trampolines for sigsetjmp and siglongjmp save and restore mask.
*
*/
FRAMESZ= MKFSIZ(1,1)
GPOFF= FRAMESZ-2*REGSZ
void LEAF(sigsetjmp, FRAMESZ)
_vwarnx(const char *fmt, va_list ap) PTR_SUBU sp, FRAMESZ
{ SETUP_GP64(GPOFF, sigsetjmp)
(void)fprintf(stderr, "%s: ", __progname); .set reorder
if (fmt != NULL) REG_S a1, (_JBLEN*REGSZ)(a0) # save "savemask"
(void)vfprintf(stderr, fmt, ap); bne a1, 0x0, 1f # do saving of signal mask?
(void)fprintf(stderr, "\n"); LA t9, _setjmp
} RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
__weak_alias(vwarnx, _vwarnx); 1: LA t9, setjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
END(sigsetjmp)
LEAF(siglongjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, siglongjmp)
.set reorder
REG_L t0, (_JBLEN*REGSZ)(a0) # get "savemask"
bne t0, 0x0, 1f # restore signal mask?
LA t9, _longjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
1:
LA t9, longjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
END(siglongjmp)

View File

@@ -28,7 +28,9 @@
#ifndef _MIPS64_ASM_H #ifndef _MIPS64_ASM_H
#define _MIPS64_ASM_H #define _MIPS64_ASM_H
#define __bionic_asm_align 4 #ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 4
#endif
#undef __bionic_asm_custom_entry #undef __bionic_asm_custom_entry
#undef __bionic_asm_custom_end #undef __bionic_asm_custom_end

View File

@@ -0,0 +1,70 @@
/* $OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */
/*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_ENDIAN_H_
#define _MIPS64_ENDIAN_H_
#ifdef __GNUC__
#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
#define __swap16md(x) ({ \
register uint16_t _x = (x); \
register uint16_t _r; \
__asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x)); \
_r; \
})
#define __swap32md(x) ({ \
register uint32_t _x = (x); \
register uint32_t _r; \
__asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \
_r; \
})
#define __swap64md(x) ({ \
uint64_t _swap64md_x = (x); \
(uint64_t) __swap32md(_swap64md_x >> 32) | \
(uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \
})
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define MD_SWAP
#endif /* __mips32r2__ */
#endif /* __GNUC__ */
#if defined(__MIPSEB__)
#define _BYTE_ORDER _BIG_ENDIAN
#else
#define _BYTE_ORDER _LITTLE_ENDIAN
#endif
#define __STRICT_ALIGNMENT
#include <sys/types.h>
#include <sys/endian.h>
#endif /* _MIPS64_ENDIAN_H_ */

View File

@@ -0,0 +1,188 @@
/* $OpenBSD: exec.h,v 1.1 2004/10/18 19:05:36 grange Exp $ */
/*
* Copyright (c) 1996-2004 Per Fogelstrom, Opsycon AB
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_EXEC_H_
#define _MIPS64_EXEC_H_
#define __LDPGSZ 4096
/*
* Define what exec "formats" we should handle.
*/
#define NATIVE_EXEC_ELF
#define NATIVE_ELFSIZE 64
#define EXEC_SCRIPT
/*
* If included from sys/exec.h define kernels ELF format.
*/
#ifdef __LP64__
#define ARCH_ELFSIZE 64
#define DB_ELFSIZE 64
#define ELF_TARG_CLASS ELFCLASS64
#else
#define ARCH_ELFSIZE 32
#define DB_ELFSIZE 32
#define ELF_TARG_CLASS ELFCLASS32
#endif
#if defined(__MIPSEB__)
#define ELF_TARG_DATA ELFDATA2MSB
#else
#define ELF_TARG_DATA ELFDATA2LSB
#endif
#define ELF_TARG_MACH EM_MIPS
#define _NLIST_DO_ELF
#if defined(_LP64)
#define _KERN_DO_ELF64
#if defined(COMPAT_O32)
#define _KERN_DO_ELF
#endif
#else
#define _KERN_DO_ELF
#endif
/* Information taken from MIPS ABI supplemental */
/* Architecture dependent Segment types - p_type */
#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
/* Architecture dependent d_tag field for Elf32_Dyn. */
#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime Linker Interface ID */
#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
#define DT_MIPS_ICHECKSUM 0x70000003 /* Cksum of ext. str. and com. sizes */
#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
#define DT_MIPS_FLAGS 0x70000005 /* Flags */
#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Segment base address */
#define DT_MIPS_CONFLICT 0x70000008 /* Adr of .conflict section */
#define DT_MIPS_LIBLIST 0x70000009 /* Address of .liblist section */
#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local .GOT entries */
#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of .conflict entries */
#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of .liblist entries */
#define DT_MIPS_SYMTABNO 0x70000011 /* Number of .dynsym entries */
#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in .dynsym */
#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
#define DT_MIPS_RLD_MAP 0x70000016 /* Address of debug map pointer */
#define DT_PROCNUM (DT_MIPS_RLD_MAP - DT_LOPROC + 1)
/*
* Legal values for e_flags field of Elf32_Ehdr.
*/
#define EF_MIPS_NOREORDER 0x00000001 /* .noreorder was used */
#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */
#define EF_MIPS_CPIC 0x00000004 /* Uses PIC calling sequence */
#define EF_MIPS_ABI2 0x00000020 /* -n32 on Irix 6 */
#define EF_MIPS_32BITMODE 0x00000100 /* 64 bit in 32 bit mode... */
#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
#define E_MIPS_ARCH_1 0x00000000
#define E_MIPS_ARCH_2 0x10000000
#define E_MIPS_ARCH_3 0x20000000
#define E_MIPS_ARCH_4 0x30000000
#define EF_MIPS_ABI 0x0000f000 /* ABI level */
#define E_MIPS_ABI_NONE 0x00000000 /* ABI level not set */
#define E_MIPS_ABI_O32 0x00001000
#define E_MIPS_ABI_O64 0x00002000
#define E_MIPS_ABI_EABI32 0x00004000
#define E_MIPS_ABI_EABI64 0x00004000
/*
* Mips special sections.
*/
#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
/*
* Legal values for sh_type field of Elf32_Shdr.
*/
#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information */
#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
/*
* Legal values for sh_flags field of Elf32_Shdr.
*/
#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
#if 0
/*
* Entries found in sections of type SHT_MIPS_GPTAB.
*/
typedef union {
struct {
Elf32_Word gt_current_g_value; /* -G val used in compilation */
Elf32_Word gt_unused; /* Not used */
} gt_header; /* First entry in section */
struct {
Elf32_Word gt_g_value; /* If this val were used for -G */
Elf32_Word gt_bytes; /* This many bytes would be used */
} gt_entry; /* Subsequent entries in section */
} Elf32_gptab;
/*
* Entry found in sections of type SHT_MIPS_REGINFO.
*/
typedef struct {
Elf32_Word ri_gprmask; /* General registers used */
Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
Elf32_Sword ri_gp_value; /* $gp register value */
} Elf32_RegInfo;
#endif
/*
* Mips relocations.
*/
#define R_MIPS_NONE 0 /* No reloc */
#define R_MIPS_16 1 /* Direct 16 bit */
#define R_MIPS_32 2 /* Direct 32 bit */
#define R_MIPS_REL32 3 /* PC relative 32 bit */
#define R_MIPS_26 4 /* Direct 26 bit shifted */
#define R_MIPS_HI16 5 /* High 16 bit */
#define R_MIPS_LO16 6 /* Low 16 bit */
#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
#define R_MIPS_PC16 10 /* PC relative 16 bit */
#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
#define R_MIPS_64 18
#define R_MIPS_REL32_64 ((R_MIPS_64 << 8) | R_MIPS_REL32)
#endif /* !_MIPS64_EXEC_H_ */

View File

@@ -37,13 +37,6 @@
#ifndef _MIPS_REGDEF_H_ #ifndef _MIPS_REGDEF_H_
#define _MIPS_REGDEF_H_ #define _MIPS_REGDEF_H_
#if (_MIPS_SIM == _ABI64) && !defined(__mips_n64)
#define __mips_n64 1
#endif
#if (_MIPS_SIM == _ABIN32) && !defined(__mips_n32)
#define __mips_n32 1
#endif
#define zero $0 /* always zero */ #define zero $0 /* always zero */
#define AT $at /* assembler temp */ #define AT $at /* assembler temp */
#define v0 $2 /* return value */ #define v0 $2 /* return value */

View File

@@ -0,0 +1,119 @@
/* $OpenBSD: regnum.h,v 1.3 2004/08/10 20:28:13 deraadt Exp $ */
/*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_REGNUM_H_
#define _MIPS64_REGNUM_H_
/*
* Location of the saved registers relative to ZERO.
* Usage is p->p_regs[XX].
*/
#define ZERO 0
#define AST 1
#define V0 2
#define V1 3
#define A0 4
#define A1 5
#define A2 6
#define A3 7
#define T0 8
#define T1 9
#define T2 10
#define T3 11
#define T4 12
#define T5 13
#define T6 14
#define T7 15
#define S0 16
#define S1 17
#define S2 18
#define S3 19
#define S4 20
#define S5 21
#define S6 22
#define S7 23
#define T8 24
#define T9 25
#define K0 26
#define K1 27
#define GP 28
#define SP 29
#define S8 30
#define RA 31
#define SR 32
#define PS SR /* alias for SR */
#define MULLO 33
#define MULHI 34
#define BADVADDR 35
#define CAUSE 36
#define PC 37
#define IC 38
#define CPL 39
#define NUMSAVEREGS 40 /* Number of registers saved in trap */
#define FPBASE NUMSAVEREGS
#define F0 (FPBASE+0)
#define F1 (FPBASE+1)
#define F2 (FPBASE+2)
#define F3 (FPBASE+3)
#define F4 (FPBASE+4)
#define F5 (FPBASE+5)
#define F6 (FPBASE+6)
#define F7 (FPBASE+7)
#define F8 (FPBASE+8)
#define F9 (FPBASE+9)
#define F10 (FPBASE+10)
#define F11 (FPBASE+11)
#define F12 (FPBASE+12)
#define F13 (FPBASE+13)
#define F14 (FPBASE+14)
#define F15 (FPBASE+15)
#define F16 (FPBASE+16)
#define F17 (FPBASE+17)
#define F18 (FPBASE+18)
#define F19 (FPBASE+19)
#define F20 (FPBASE+20)
#define F21 (FPBASE+21)
#define F22 (FPBASE+22)
#define F23 (FPBASE+23)
#define F24 (FPBASE+24)
#define F25 (FPBASE+25)
#define F26 (FPBASE+26)
#define F27 (FPBASE+27)
#define F28 (FPBASE+28)
#define F29 (FPBASE+29)
#define F30 (FPBASE+30)
#define F31 (FPBASE+31)
#define FSR (FPBASE+32)
#define NUMFPREGS 33
#define NREGS (NUMSAVEREGS + NUMFPREGS)
#endif /* !_MIPS64_REGNUM_H_ */

View File

@@ -5,10 +5,6 @@
#ifndef _MIPS_SETJMP_H_ #ifndef _MIPS_SETJMP_H_
#define _MIPS_SETJMP_H_ #define _MIPS_SETJMP_H_
#ifdef __LP64__ #define _JBLEN 157 /* size, in longs, of a jmp_buf */
#define _JBLEN 22 /* size, in 8-byte longs, of a mips64 jmp_buf */
#else
#define _JBLEN 29 /* size, in 4-byte longs, of a mips32 jmp_buf */
#endif
#endif /* !_MIPS_SETJMP_H_ */ #endif /* !_MIPS_SETJMP_H_ */

View File

@@ -1,8 +1,12 @@
/* $OpenBSD: daemon.c,v 1.7 2010/07/27 22:29:09 marco Exp $ */ /* $OpenBSD: signal.h,v 1.8 2006/01/09 18:18:37 millert Exp $ */
/*-
* Copyright (c) 1990, 1993 /*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@@ -26,39 +30,22 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*
* @(#)signal.h 8.1 (Berkeley) 6/10/93
*/ */
#include <fcntl.h> #ifndef _MIPS_SIGNAL_H_
#include <paths.h> #define _MIPS_SIGNAL_H_
#include <unistd.h>
#include <stdlib.h>
int #define SC_REGMASK (0*REGSZ)
daemon(int nochdir, int noclose) #define SC_STATUS (1*REGSZ)
{ #define SC_PC (2*REGSZ)
int fd; #define SC_REGS (SC_PC+8)
#define SC_FPREGS (SC_REGS+32*8)
#define SC_ACX (SC_FPREGS+32*REGSZ_FP)
#define SC_USED_MATH (SC_ACX+3*REGSZ)
/* OpenBSD compatibility */
#define SC_MASK SC_REGMASK
#define SC_FPUSED SC_USED_MATH
switch (fork()) { #endif /* !_MIPS_SIGNAL_H_ */
case -1:
return (-1);
case 0:
break;
default:
_exit(0);
}
if (setsid() == -1)
return (-1);
if (!nochdir)
(void)chdir("/");
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);
if (fd > 2)
(void)close(fd);
}
return (0);
}

View File

@@ -67,7 +67,9 @@ libc_bionic_src_files_mips += \
arch-mips/bionic/bzero.S \ arch-mips/bionic/bzero.S \
arch-mips/bionic/cacheflush.cpp \ arch-mips/bionic/cacheflush.cpp \
arch-mips/bionic/_exit_with_stack_teardown.S \ arch-mips/bionic/_exit_with_stack_teardown.S \
arch-mips/bionic/_setjmp.S \
arch-mips/bionic/setjmp.S \ arch-mips/bionic/setjmp.S \
arch-mips/bionic/sigsetjmp.S \
arch-mips/bionic/syscall.S \ arch-mips/bionic/syscall.S \
arch-mips/bionic/vfork.S \ arch-mips/bionic/vfork.S \

View File

@@ -30,7 +30,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <string.h>
#include "mips-string-ops.h" #include "mips-string-ops.h"
#define do_strlen_word(__av) {\ #define do_strlen_word(__av) {\
@@ -48,8 +47,8 @@
#define strlen my_strlen #define strlen my_strlen
#endif #endif
size_t int
strlen (const char *_a) strlen (const void *_a)
{ {
int cnt = 0; int cnt = 0;
unsigned x; unsigned x;

View File

@@ -1,19 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(__rt_sigqueueinfo)
.set noreorder
.cpload t9
li v0, __NR_rt_sigqueueinfo
syscall
bnez a3, 1f
move a0, v0
j ra
nop
1:
la t9,__set_errno_internal
j t9
nop
.set reorder
END(__rt_sigqueueinfo)

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(__clock_nanosleep) ENTRY(clock_nanosleep)
.set noreorder .set noreorder
.cpload t9 .cpload t9
li v0, __NR_clock_nanosleep li v0, __NR_clock_nanosleep
@@ -16,4 +16,4 @@ ENTRY(__clock_nanosleep)
j t9 j t9
nop nop
.set reorder .set reorder
END(__clock_nanosleep) END(clock_nanosleep)

View File

@@ -1,19 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(sethostname)
.set noreorder
.cpload t9
li v0, __NR_sethostname
syscall
bnez a3, 1f
move a0, v0
j ra
nop
1:
la t9,__set_errno_internal
j t9
nop
.set reorder
END(sethostname)

View File

@@ -0,0 +1,150 @@
/* $OpenBSD: _setjmp.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
/*
* Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of Opsycon AB nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*
*/
#include <private/bionic_asm.h>
#include <machine/regnum.h>
#include <machine/signal.h>
/*
* _setjmp, _longjmp (not restoring signal state)
*
* XXX FPSET should probably be taken from SR setting. hmmm...
* GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
*
*/
FRAMESZ= MKFSIZ(0,4)
GPOFF= FRAMESZ-2*REGSZ
LEAF(_setjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _setjmp)
SAVE_GP(GPOFF)
.set noreorder
#if defined(__mips64)
dli v0, 0xACEDBADE # sigcontext magic number
#else
li v0, 0xACEDBADE # sigcontext magic number
#endif
REG_S v0, SC_REGS+ZERO*REGSZ(a0)
REG_S s0, SC_REGS+S0*REGSZ(a0)
REG_S s1, SC_REGS+S1*REGSZ(a0)
REG_S s2, SC_REGS+S2*REGSZ(a0)
REG_S s3, SC_REGS+S3*REGSZ(a0)
REG_S s4, SC_REGS+S4*REGSZ(a0)
REG_S s5, SC_REGS+S5*REGSZ(a0)
REG_S s6, SC_REGS+S6*REGSZ(a0)
REG_S s7, SC_REGS+S7*REGSZ(a0)
REG_S s8, SC_REGS+S8*REGSZ(a0)
REG_L v0, GPOFF(sp)
REG_S v0, SC_REGS+GP*REGSZ(a0)
PTR_ADDU v0, sp, FRAMESZ
REG_S v0, SC_REGS+SP*REGSZ(a0)
REG_S ra, SC_PC(a0)
#if !defined(SOFTFLOAT)
li v0, 1 # be nice if we could tell
REG_S v0, SC_FPUSED(a0) # sc_fpused = 1
cfc1 v0, $31
s.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
s.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
s.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
s.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
s.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
s.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
s.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
s.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
s.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
s.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
s.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
s.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
REG_S v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
#endif /* !SOFTFLOAT */
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
j ra
move v0, zero
END(_setjmp)
LEAF(_longjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, _longjmp)
SAVE_GP(GPOFF)
.set noreorder
REG_L v0, SC_REGS+ZERO*REGSZ(a0)
bne v0, 0xACEDBADE, botch # jump if error
REG_L ra, SC_PC(a0)
REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
REG_L s0, SC_REGS+S0*REGSZ(a0)
REG_L s1, SC_REGS+S1*REGSZ(a0)
REG_L s2, SC_REGS+S2*REGSZ(a0)
REG_L s3, SC_REGS+S3*REGSZ(a0)
REG_L s4, SC_REGS+S4*REGSZ(a0)
REG_L s5, SC_REGS+S5*REGSZ(a0)
REG_L s6, SC_REGS+S6*REGSZ(a0)
REG_L s7, SC_REGS+S7*REGSZ(a0)
REG_L s8, SC_REGS+S8*REGSZ(a0)
REG_L gp, SC_REGS+GP*REGSZ(a0)
REG_L sp, SC_REGS+SP*REGSZ(a0)
#if !defined(SOFTFLOAT)
ctc1 v0, $31
l.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
l.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
l.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
l.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
l.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
l.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
l.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
l.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
l.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
l.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
l.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
l.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
#endif /* !SOFTFLOAT */
bne a1, zero, 1f
nop
li a1, 1 # never return 0!
1:
j ra
move v0, a1
botch:
jal longjmperror
nop
jal abort
nop
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
END(_longjmp)

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*/
extern void *__dso_handle;
extern int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
__attribute__ ((visibility ("hidden")))
int atexit(void (*func)(void))
{
return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
}

View File

@@ -91,4 +91,4 @@ __asm__ (
); );
#include "../../arch-common/bionic/__dso_handle.h" #include "../../arch-common/bionic/__dso_handle.h"
#include "../../arch-common/bionic/atexit.h" #include "atexit.h"

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*/
extern void __cxa_finalize(void *);
extern void *__dso_handle;
__attribute__((visibility("hidden"),destructor))
void __on_dlclose() {
__cxa_finalize(&__dso_handle);
}
#include "../../arch-common/bionic/__dso_handle_so.h"
#include "atexit.h"

View File

@@ -1 +0,0 @@
../../arch-mips/bionic/setjmp.S

View File

@@ -0,0 +1,174 @@
/* $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
/*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of Opsycon AB nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* 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.
*
*/
#include <private/bionic_asm.h>
#include <machine/regnum.h>
#include <machine/signal.h>
/*
* setjmp, longjmp implementation for libc. this code depends
* on the layout of the struct sigcontext in machine/signal.h.
*
*/
FRAMESZ= MKFSIZ(2,6)
A1OFF= FRAMESZ-4*REGSZ
A0OFF= FRAMESZ-3*REGSZ
GPOFF= FRAMESZ-2*REGSZ
RAOFF= FRAMESZ-1*REGSZ
NON_LEAF(setjmp, FRAMESZ, ra)
.mask 0x80000000, RAOFF
PTR_SUBU sp, FRAMESZ # allocate stack frame
SETUP_GP64(GPOFF, setjmp)
SAVE_GP(GPOFF)
.set reorder
REG_S ra, RAOFF(sp) # save state
REG_S a0, A0OFF(sp)
move a0, zero # get current signal mask
jal sigblock
REG_L v1, A0OFF(sp) # v1 = jmpbuf
REG_S v0, SC_MASK(v1) # save sc_mask = sigblock(0)
REG_L a0, A0OFF(sp) # restore jmpbuf
REG_L ra, RAOFF(sp)
REG_S ra, SC_PC(a0) # sc_pc = return address
#if defined(__mips64)
dli v0, 0xACEDBADE # sigcontext magic number
#else
li v0, 0xACEDBADE # sigcontext magic number
#endif
REG_S v0, SC_REGS+ZERO*REGSZ(a0)
REG_S s0, SC_REGS+S0*REGSZ(a0)
REG_S s1, SC_REGS+S1*REGSZ(a0)
REG_S s2, SC_REGS+S2*REGSZ(a0)
REG_S s3, SC_REGS+S3*REGSZ(a0)
REG_S s4, SC_REGS+S4*REGSZ(a0)
REG_S s5, SC_REGS+S5*REGSZ(a0)
REG_S s6, SC_REGS+S6*REGSZ(a0)
REG_S s7, SC_REGS+S7*REGSZ(a0)
REG_S s8, SC_REGS+S8*REGSZ(a0)
REG_L v0, GPOFF(sp)
REG_S v0, SC_REGS+GP*REGSZ(a0)
PTR_ADDU v0, sp, FRAMESZ
REG_S v0, SC_REGS+SP*REGSZ(a0)
#if !defined(SOFTFLOAT)
li v0, 1 # be nice if we could tell
REG_S v0, SC_FPUSED(a0) # sc_fpused = 1
cfc1 v0, $31
s.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
s.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
s.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
s.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
s.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
s.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
s.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
s.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
s.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
s.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
s.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
s.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
REG_S v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
#endif /* !SOFTFLOAT */
move v0, zero
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
j ra
botch:
jal longjmperror
jal abort
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
END(setjmp)
LEAF(longjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, longjmp)
SAVE_GP(GPOFF)
.set reorder
sw a1, A1OFF(sp)
sw a0, A0OFF(sp)
lw a0, SC_MASK(a0)
jal sigsetmask
lw a0, A0OFF(sp)
lw a1, A1OFF(sp)
.set noreorder
REG_L v0, SC_REGS+ZERO*REGSZ(a0)
bne v0, 0xACEDBADE, botch # jump if error
REG_L ra, SC_PC(a0)
REG_L s0, SC_REGS+S0*REGSZ(a0)
REG_L s1, SC_REGS+S1*REGSZ(a0)
REG_L s2, SC_REGS+S2*REGSZ(a0)
REG_L s3, SC_REGS+S3*REGSZ(a0)
REG_L s4, SC_REGS+S4*REGSZ(a0)
REG_L s5, SC_REGS+S5*REGSZ(a0)
REG_L s6, SC_REGS+S6*REGSZ(a0)
REG_L s7, SC_REGS+S7*REGSZ(a0)
REG_L s8, SC_REGS+S8*REGSZ(a0)
REG_L gp, SC_REGS+GP*REGSZ(a0)
REG_L sp, SC_REGS+SP*REGSZ(a0)
#if !defined(SOFTFLOAT)
REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
ctc1 v0, $31
l.d $f20, SC_FPREGS+((F20-F0)*REGSZ_FP)(a0)
l.d $f22, SC_FPREGS+((F22-F0)*REGSZ_FP)(a0)
l.d $f24, SC_FPREGS+((F24-F0)*REGSZ_FP)(a0)
l.d $f26, SC_FPREGS+((F26-F0)*REGSZ_FP)(a0)
l.d $f28, SC_FPREGS+((F28-F0)*REGSZ_FP)(a0)
l.d $f30, SC_FPREGS+((F30-F0)*REGSZ_FP)(a0)
#if _MIPS_FPSET == 32
l.d $f21, SC_FPREGS+((F21-F0)*REGSZ_FP)(a0)
l.d $f23, SC_FPREGS+((F23-F0)*REGSZ_FP)(a0)
l.d $f25, SC_FPREGS+((F25-F0)*REGSZ_FP)(a0)
l.d $f27, SC_FPREGS+((F27-F0)*REGSZ_FP)(a0)
l.d $f29, SC_FPREGS+((F29-F0)*REGSZ_FP)(a0)
l.d $f31, SC_FPREGS+((F31-F0)*REGSZ_FP)(a0)
#endif
#endif /* !SOFTFLOAT */
bne a1, zero, 1f
nop
li a1, 1 # never return 0!
1:
j ra
move v0, a1
END(longjmp)

View File

@@ -0,0 +1,77 @@
/* $OpenBSD: sigsetjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
/*-
* Copyright (c) 1991, 1993, 1995,
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Havard Eidnes.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
#include <private/bionic_asm.h>
#include <machine/regnum.h>
#include <machine/setjmp.h>
/*
* trampolines for sigsetjmp and siglongjmp save and restore mask.
*
*/
FRAMESZ= MKFSIZ(1,1)
GPOFF= FRAMESZ-2*REGSZ
LEAF(sigsetjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, sigsetjmp)
.set reorder
REG_S a1, (_JBLEN*REGSZ)(a0) # save "savemask"
bne a1, 0x0, 1f # do saving of signal mask?
LA t9, _setjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
1: LA t9, setjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
END(sigsetjmp)
LEAF(siglongjmp, FRAMESZ)
PTR_SUBU sp, FRAMESZ
SETUP_GP64(GPOFF, siglongjmp)
.set reorder
REG_L t0, (_JBLEN*REGSZ)(a0) # get "savemask"
bne t0, 0x0, 1f # restore signal mask?
LA t9, _longjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
1:
LA t9, longjmp
RESTORE_GP64
PTR_ADDU sp, FRAMESZ
jr t9
END(siglongjmp)

View File

@@ -52,7 +52,7 @@ LEAF(syscall,FRAMESZ)
#else #else
move a3, a4 move a3, a4
move a4, a5 move a4, a5
move a5, a6 REG_L a5, FRAMESZ(sp)
#endif #endif
syscall syscall
move a0, v0 move a0, v0

View File

@@ -1 +0,0 @@
../../arch-mips/include/machine

View File

@@ -0,0 +1,208 @@
/* $OpenBSD: asm.h,v 1.7 2004/10/20 12:49:15 pefo Exp $ */
/*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_ASM_H
#define _MIPS64_ASM_H
#ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 4
#endif
#undef __bionic_asm_custom_entry
#undef __bionic_asm_custom_end
#define __bionic_asm_custom_entry(f) .ent f
#define __bionic_asm_custom_end(f) .end f
#include <machine/regdef.h>
#define _MIPS_ISA_MIPS1 1 /* R2000/R3000 */
#define _MIPS_ISA_MIPS2 2 /* R4000/R6000 */
#define _MIPS_ISA_MIPS3 3 /* R4000 */
#define _MIPS_ISA_MIPS4 4 /* TFP (R1x000) */
#define _MIPS_ISA_MIPS5 5
#define _MIPS_ISA_MIPS32 6
#define _MIPS_ISA_MIPS64 7
#if !defined(ABICALLS) && !defined(_NO_ABICALLS)
#define ABICALLS .abicalls
#endif
#if defined(ABICALLS) && !defined(_KERNEL)
ABICALLS
#endif
#if !defined(__MIPSEL__) && !defined(__MIPSEB__)
#error "__MIPSEL__ or __MIPSEB__ must be defined"
#endif
/*
* Define how to access unaligned data word
*/
#if defined(__MIPSEL__)
#define LWLO lwl
#define LWHI lwr
#define SWLO swl
#define SWHI swr
#define LDLO ldl
#define LDHI ldr
#define SDLO sdl
#define SDHI sdr
#endif
#if defined(__MIPSEB__)
#define LWLO lwr
#define LWHI lwl
#define SWLO swr
#define SWHI swl
#define LDLO ldr
#define LDHI ldl
#define SDLO sdr
#define SDHI sdl
#endif
/*
* Define programming environment for ABI.
*/
#if defined(ABICALLS) && !defined(_KERNEL) && !defined(_STANDALONE)
#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
#define NARGSAVE 4
#define SETUP_GP \
.set noreorder; \
.cpload t9; \
.set reorder;
#define SAVE_GP(x) \
.cprestore x
#define SETUP_GP64(gpoff, name)
#define RESTORE_GP64
#endif
#if (_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32)
#define NARGSAVE 0
#define SETUP_GP
#define SAVE_GP(x)
#define SETUP_GP64(gpoff, name) \
.cpsetup t9, gpoff, name
#define RESTORE_GP64 \
.cpreturn
#endif
#define MKFSIZ(narg,locals) (((narg+locals)*REGSZ+31)&(~31))
#else /* defined(ABICALLS) && !defined(_KERNEL) */
#define NARGSAVE 4
#define SETUP_GP
#define SAVE_GP(x)
#define ALIGNSZ 16 /* Stack layout alignment */
#define FRAMESZ(sz) (((sz) + (ALIGNSZ-1)) & ~(ALIGNSZ-1))
#endif
/*
* Basic register operations based on selected ISA
*/
#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2 || _MIPS_ISA == _MIPS_ISA_MIPS32)
#define REGSZ 4 /* 32 bit mode register size */
#define LOGREGSZ 2 /* log rsize */
#define REG_S sw
#define REG_L lw
#define CF_SZ 24 /* Call frame size */
#define CF_ARGSZ 16 /* Call frame arg size */
#define CF_RA_OFFS 20 /* Call ra save offset */
#endif
#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || _MIPS_ISA == _MIPS_ISA_MIPS64)
#define REGSZ 8 /* 64 bit mode register size */
#define LOGREGSZ 3 /* log rsize */
#define REG_S sd
#define REG_L ld
#define CF_SZ 48 /* Call frame size (multiple of ALIGNSZ) */
#define CF_ARGSZ 32 /* Call frame arg size */
#define CF_RA_OFFS 40 /* Call ra save offset */
#endif
#define REGSZ_FP 8 /* 64 bit FP register size */
#ifndef __LP64__
#define PTR_L lw
#define PTR_S sw
#define PTR_SUB sub
#define PTR_ADD add
#define PTR_SUBU subu
#define PTR_ADDU addu
#define LI li
#define LA la
#define PTR_SLL sll
#define PTR_SRL srl
#define PTR_VAL .word
#else
#define PTR_L ld
#define PTR_S sd
#define PTR_ADD dadd
#define PTR_SUB dsub
#define PTR_SUBU dsubu
#define PTR_ADDU daddu
#define LI dli
#define LA dla
#define PTR_SLL dsll
#define PTR_SRL dsrl
#define PTR_VAL .dword
#endif
/*
* LEAF(x, fsize)
*
* Declare a leaf routine.
*/
#define LEAF(x, fsize) \
.align 3; \
.globl x; \
.ent x, 0; \
x: ; \
.cfi_startproc; \
.frame sp, fsize, ra; \
SETUP_GP \
/*
* NON_LEAF(x)
*
* Declare a non-leaf routine (a routine that makes other C calls).
*/
#define NON_LEAF(x, fsize, retpc) \
.align 3; \
.globl x; \
.ent x, 0; \
x: ; \
.cfi_startproc; \
.frame sp, fsize, retpc; \
SETUP_GP \
#endif /* !_MIPS_ASM_H */

View File

@@ -0,0 +1,196 @@
/* $NetBSD: elf_machdep.h,v 1.15 2011/03/15 07:39:22 matt Exp $ */
#ifndef _MIPS_ELF_MACHDEP_H_
#define _MIPS_ELF_MACHDEP_H_
#ifdef _LP64
#define ARCH_ELFSIZE 64 /* MD native binary size */
#else
#define ARCH_ELFSIZE 32 /* MD native binary size */
#endif
#if ELFSIZE == 32
#define ELF32_MACHDEP_ID_CASES \
case EM_MIPS: \
break;
#define ELF32_MACHDEP_ID EM_MIPS
#elif ELFSIZE == 64
#define ELF64_MACHDEP_ID_CASES \
case EM_MIPS: \
break;
#define ELF64_MACHDEP_ID EM_MIPS
#endif
/* mips relocs. */
#define R_MIPS_NONE 0
#define R_MIPS_16 1
#define R_MIPS_32 2
#define R_MIPS_REL32 3
#define R_MIPS_REL R_MIPS_REL32
#define R_MIPS_26 4
#define R_MIPS_HI16 5 /* high 16 bits of symbol value */
#define R_MIPS_LO16 6 /* low 16 bits of symbol value */
#define R_MIPS_GPREL16 7 /* GP-relative reference */
#define R_MIPS_LITERAL 8 /* Reference to literal section */
#define R_MIPS_GOT16 9 /* Reference to global offset table */
#define R_MIPS_GOT R_MIPS_GOT16
#define R_MIPS_PC16 10 /* 16 bit PC relative reference */
#define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */
#define R_MIPS_CALL R_MIPS_CALL16
#define R_MIPS_GPREL32 12
/* 13, 14, 15 are not defined at this point. */
#define R_MIPS_UNUSED1 13
#define R_MIPS_UNUSED2 14
#define R_MIPS_UNUSED3 15
/*
* The remaining relocs are apparently part of the 64-bit Irix ELF ABI.
*/
#define R_MIPS_SHIFT5 16
#define R_MIPS_SHIFT6 17
#define R_MIPS_64 18
#define R_MIPS_GOT_DISP 19
#define R_MIPS_GOT_PAGE 20
#define R_MIPS_GOT_OFST 21
#define R_MIPS_GOT_HI16 22
#define R_MIPS_GOT_LO16 23
#define R_MIPS_SUB 24
#define R_MIPS_INSERT_A 25
#define R_MIPS_INSERT_B 26
#define R_MIPS_DELETE 27
#define R_MIPS_HIGHER 28
#define R_MIPS_HIGHEST 29
#define R_MIPS_CALL_HI16 30
#define R_MIPS_CALL_LO16 31
#define R_MIPS_SCN_DISP 32
#define R_MIPS_REL16 33
#define R_MIPS_ADD_IMMEDIATE 34
#define R_MIPS_PJUMP 35
#define R_MIPS_RELGOT 36
#define R_MIPS_JALR 37
/* TLS relocations */
#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */
#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */
#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */
#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */
#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */
#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */
#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */
#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */
#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */
#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */
#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
#define R_MIPS_max 51
#define R_TYPE(name) __CONCAT(R_MIPS_,name)
#define R_MIPS16_min 100
#define R_MIPS16_26 100
#define R_MIPS16_GPREL 101
#define R_MIPS16_GOT16 102
#define R_MIPS16_CALL16 103
#define R_MIPS16_HI16 104
#define R_MIPS16_LO16 105
#define R_MIPS16_max 106
/* mips dynamic tags */
#define DT_MIPS_RLD_VERSION 0x70000001
#define DT_MIPS_TIME_STAMP 0x70000002
#define DT_MIPS_ICHECKSUM 0x70000003
#define DT_MIPS_IVERSION 0x70000004
#define DT_MIPS_FLAGS 0x70000005
#define DT_MIPS_BASE_ADDRESS 0x70000006
#define DT_MIPS_CONFLICT 0x70000008
#define DT_MIPS_LIBLIST 0x70000009
#define DT_MIPS_CONFLICTNO 0x7000000b
#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */
#define DT_MIPS_LIBLISTNO 0x70000010
#define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */
#define DT_MIPS_UNREFEXTNO 0x70000012
#define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */
#define DT_MIPS_HIPAGENO 0x70000014
#define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */
/*
* ELF Flags
*/
#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */
#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */
#define EF_MIPS_ABI2 0x00000020 /* N32 */
#define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */
#define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */
#define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */
#define EF_MIPS_ARCH 0xf0000000 /* Architecture field */
#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */
#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */
#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */
#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */
#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */
#define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */
#define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */
#define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */
#define EF_MIPS_ARCH_64R2 0x80000000 /* -mips64r2 code */
#define EF_MIPS_ABI 0x0000f000
#define EF_MIPS_ABI_O32 0x00001000
#define EF_MIPS_ABI_O64 0x00002000
#define EF_MIPS_ABI_EABI32 0x00003000
#define EF_MIPS_ABI_EABI64 0x00004000
#if defined(__MIPSEB__)
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB
#elif defined(__MIPSEL__)
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
#elif !defined(HAVE_NBTOOL_CONFIG_H)
#error neither __MIPSEL__ nor __MIPSEB__ are defined.
#endif
#ifdef _KERNEL
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
#endif
#ifdef COMPAT_16
/*
* Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable.
* Tell the kernel ELF exec code not to try relocating the interpreter
* for dynamically-linked ELF binaries.
*/
#define ELF_INTERP_NON_RELOCATABLE
#endif /* COMPAT_16 */
/*
* We need to be able to include the ELF header so we can pick out the
* ABI being used.
*/
#ifdef ELFSIZE
#define ELF_MD_PROBE_FUNC ELFNAME2(mips_netbsd,probe)
#define ELF_MD_COREDUMP_SETUP ELFNAME2(coredump,setup)
#endif
struct exec_package;
int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
vaddr_t *);
void coredump_elf32_setup(struct lwp *, void *);
int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
vaddr_t *);
void coredump_elf64_setup(struct lwp *, void *);
#endif /* _KERNEL */
#endif /* _MIPS_ELF_MACHDEP_H_ */

View File

@@ -0,0 +1,70 @@
/* $OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */
/*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_ENDIAN_H_
#define _MIPS64_ENDIAN_H_
#ifdef __GNUC__
#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
#define __swap16md(x) ({ \
register uint16_t _x = (x); \
register uint16_t _r; \
__asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x)); \
_r; \
})
#define __swap32md(x) ({ \
register uint32_t _x = (x); \
register uint32_t _r; \
__asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \
_r; \
})
#define __swap64md(x) ({ \
uint64_t _swap64md_x = (x); \
(uint64_t) __swap32md(_swap64md_x >> 32) | \
(uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \
})
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define MD_SWAP
#endif /* __mips32r2__ */
#endif /* __GNUC__ */
#if defined(__MIPSEB__)
#define _BYTE_ORDER _BIG_ENDIAN
#else
#define _BYTE_ORDER _LITTLE_ENDIAN
#endif
#define __STRICT_ALIGNMENT
#include <sys/types.h>
#include <sys/endian.h>
#endif /* _MIPS64_ENDIAN_H_ */

View File

@@ -0,0 +1,188 @@
/* $OpenBSD: exec.h,v 1.1 2004/10/18 19:05:36 grange Exp $ */
/*
* Copyright (c) 1996-2004 Per Fogelstrom, Opsycon AB
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_EXEC_H_
#define _MIPS64_EXEC_H_
#define __LDPGSZ 4096
/*
* Define what exec "formats" we should handle.
*/
#define NATIVE_EXEC_ELF
#define NATIVE_ELFSIZE 64
#define EXEC_SCRIPT
/*
* If included from sys/exec.h define kernels ELF format.
*/
#ifdef __LP64__
#define ARCH_ELFSIZE 64
#define DB_ELFSIZE 64
#define ELF_TARG_CLASS ELFCLASS64
#else
#define ARCH_ELFSIZE 32
#define DB_ELFSIZE 32
#define ELF_TARG_CLASS ELFCLASS32
#endif
#if defined(__MIPSEB__)
#define ELF_TARG_DATA ELFDATA2MSB
#else
#define ELF_TARG_DATA ELFDATA2LSB
#endif
#define ELF_TARG_MACH EM_MIPS
#define _NLIST_DO_ELF
#if defined(_LP64)
#define _KERN_DO_ELF64
#if defined(COMPAT_O32)
#define _KERN_DO_ELF
#endif
#else
#define _KERN_DO_ELF
#endif
/* Information taken from MIPS ABI supplemental */
/* Architecture dependent Segment types - p_type */
#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
/* Architecture dependent d_tag field for Elf32_Dyn. */
#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime Linker Interface ID */
#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
#define DT_MIPS_ICHECKSUM 0x70000003 /* Cksum of ext. str. and com. sizes */
#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
#define DT_MIPS_FLAGS 0x70000005 /* Flags */
#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Segment base address */
#define DT_MIPS_CONFLICT 0x70000008 /* Adr of .conflict section */
#define DT_MIPS_LIBLIST 0x70000009 /* Address of .liblist section */
#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local .GOT entries */
#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of .conflict entries */
#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of .liblist entries */
#define DT_MIPS_SYMTABNO 0x70000011 /* Number of .dynsym entries */
#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in .dynsym */
#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
#define DT_MIPS_RLD_MAP 0x70000016 /* Address of debug map pointer */
#define DT_PROCNUM (DT_MIPS_RLD_MAP - DT_LOPROC + 1)
/*
* Legal values for e_flags field of Elf32_Ehdr.
*/
#define EF_MIPS_NOREORDER 0x00000001 /* .noreorder was used */
#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */
#define EF_MIPS_CPIC 0x00000004 /* Uses PIC calling sequence */
#define EF_MIPS_ABI2 0x00000020 /* -n32 on Irix 6 */
#define EF_MIPS_32BITMODE 0x00000100 /* 64 bit in 32 bit mode... */
#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
#define E_MIPS_ARCH_1 0x00000000
#define E_MIPS_ARCH_2 0x10000000
#define E_MIPS_ARCH_3 0x20000000
#define E_MIPS_ARCH_4 0x30000000
#define EF_MIPS_ABI 0x0000f000 /* ABI level */
#define E_MIPS_ABI_NONE 0x00000000 /* ABI level not set */
#define E_MIPS_ABI_O32 0x00001000
#define E_MIPS_ABI_O64 0x00002000
#define E_MIPS_ABI_EABI32 0x00004000
#define E_MIPS_ABI_EABI64 0x00004000
/*
* Mips special sections.
*/
#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
/*
* Legal values for sh_type field of Elf32_Shdr.
*/
#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information */
#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
/*
* Legal values for sh_flags field of Elf32_Shdr.
*/
#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
#if 0
/*
* Entries found in sections of type SHT_MIPS_GPTAB.
*/
typedef union {
struct {
Elf32_Word gt_current_g_value; /* -G val used in compilation */
Elf32_Word gt_unused; /* Not used */
} gt_header; /* First entry in section */
struct {
Elf32_Word gt_g_value; /* If this val were used for -G */
Elf32_Word gt_bytes; /* This many bytes would be used */
} gt_entry; /* Subsequent entries in section */
} Elf32_gptab;
/*
* Entry found in sections of type SHT_MIPS_REGINFO.
*/
typedef struct {
Elf32_Word ri_gprmask; /* General registers used */
Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
Elf32_Sword ri_gp_value; /* $gp register value */
} Elf32_RegInfo;
#endif
/*
* Mips relocations.
*/
#define R_MIPS_NONE 0 /* No reloc */
#define R_MIPS_16 1 /* Direct 16 bit */
#define R_MIPS_32 2 /* Direct 32 bit */
#define R_MIPS_REL32 3 /* PC relative 32 bit */
#define R_MIPS_26 4 /* Direct 26 bit shifted */
#define R_MIPS_HI16 5 /* High 16 bit */
#define R_MIPS_LO16 6 /* Low 16 bit */
#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
#define R_MIPS_PC16 10 /* PC relative 16 bit */
#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
#define R_MIPS_64 18
#define R_MIPS_REL32_64 ((R_MIPS_64 << 8) | R_MIPS_REL32)
#endif /* !_MIPS64_EXEC_H_ */

View File

@@ -0,0 +1,99 @@
/* $OpenBSD: regdef.h,v 1.3 2005/08/07 07:29:44 miod Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell. This file is derived from the MIPS RISC
* Architecture book by Gerry Kane.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)regdef.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _MIPS_REGDEF_H_
#define _MIPS_REGDEF_H_
#if (_MIPS_SIM == _ABI64) && !defined(__mips_n64)
#define __mips_n64 1
#endif
#if (_MIPS_SIM == _ABIN32) && !defined(__mips_n32)
#define __mips_n32 1
#endif
#define zero $0 /* always zero */
#define AT $at /* assembler temp */
#define v0 $2 /* return value */
#define v1 $3
#define a0 $4 /* argument registers */
#define a1 $5
#define a2 $6
#define a3 $7
#if defined(__mips_n32) || defined(__mips_n64)
#define a4 $8 /* expanded register arguments */
#define a5 $9
#define a6 $10
#define a7 $11
#define ta0 $8 /* alias */
#define ta1 $9
#define ta2 $10
#define ta3 $11
#define t0 $12 /* temp registers (not saved across subroutine calls) */
#define t1 $13
#define t2 $14
#define t3 $15
#else
#define t0 $8 /* temp registers (not saved across subroutine calls) */
#define t1 $9
#define t2 $10
#define t3 $11
#define t4 $12
#define t5 $13
#define t6 $14
#define t7 $15
#define ta0 $12 /* alias */
#define ta1 $13
#define ta2 $14
#define ta3 $15
#endif
#define s0 $16 /* saved across subroutine calls (callee saved) */
#define s1 $17
#define s2 $18
#define s3 $19
#define s4 $20
#define s5 $21
#define s6 $22
#define s7 $23
#define t8 $24 /* two more temp registers */
#define t9 $25
#define k0 $26 /* kernel temporary */
#define k1 $27
#define gp $28 /* global pointer */
#define sp $29 /* stack pointer */
#define s8 $30 /* one more callee saved */
#define ra $31 /* return address */
#endif /* !_MIPS_REGDEF_H_ */

View File

@@ -0,0 +1,119 @@
/* $OpenBSD: regnum.h,v 1.3 2004/08/10 20:28:13 deraadt Exp $ */
/*
* Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*
*/
#ifndef _MIPS64_REGNUM_H_
#define _MIPS64_REGNUM_H_
/*
* Location of the saved registers relative to ZERO.
* Usage is p->p_regs[XX].
*/
#define ZERO 0
#define AST 1
#define V0 2
#define V1 3
#define A0 4
#define A1 5
#define A2 6
#define A3 7
#define T0 8
#define T1 9
#define T2 10
#define T3 11
#define T4 12
#define T5 13
#define T6 14
#define T7 15
#define S0 16
#define S1 17
#define S2 18
#define S3 19
#define S4 20
#define S5 21
#define S6 22
#define S7 23
#define T8 24
#define T9 25
#define K0 26
#define K1 27
#define GP 28
#define SP 29
#define S8 30
#define RA 31
#define SR 32
#define PS SR /* alias for SR */
#define MULLO 33
#define MULHI 34
#define BADVADDR 35
#define CAUSE 36
#define PC 37
#define IC 38
#define CPL 39
#define NUMSAVEREGS 40 /* Number of registers saved in trap */
#define FPBASE NUMSAVEREGS
#define F0 (FPBASE+0)
#define F1 (FPBASE+1)
#define F2 (FPBASE+2)
#define F3 (FPBASE+3)
#define F4 (FPBASE+4)
#define F5 (FPBASE+5)
#define F6 (FPBASE+6)
#define F7 (FPBASE+7)
#define F8 (FPBASE+8)
#define F9 (FPBASE+9)
#define F10 (FPBASE+10)
#define F11 (FPBASE+11)
#define F12 (FPBASE+12)
#define F13 (FPBASE+13)
#define F14 (FPBASE+14)
#define F15 (FPBASE+15)
#define F16 (FPBASE+16)
#define F17 (FPBASE+17)
#define F18 (FPBASE+18)
#define F19 (FPBASE+19)
#define F20 (FPBASE+20)
#define F21 (FPBASE+21)
#define F22 (FPBASE+22)
#define F23 (FPBASE+23)
#define F24 (FPBASE+24)
#define F25 (FPBASE+25)
#define F26 (FPBASE+26)
#define F27 (FPBASE+27)
#define F28 (FPBASE+28)
#define F29 (FPBASE+29)
#define F30 (FPBASE+30)
#define F31 (FPBASE+31)
#define FSR (FPBASE+32)
#define NUMFPREGS 33
#define NREGS (NUMSAVEREGS + NUMFPREGS)
#endif /* !_MIPS64_REGNUM_H_ */

View File

@@ -0,0 +1,10 @@
/* $OpenBSD: setjmp.h,v 1.2 2004/08/10 21:10:56 pefo Exp $ */
/* Public domain */
#ifndef _MIPS_SETJMP_H_
#define _MIPS_SETJMP_H_
#define _JBLEN 157 /* size, in longs, of a jmp_buf */
#endif /* !_MIPS_SETJMP_H_ */

View File

@@ -1,8 +1,12 @@
/* $OpenBSD: vwarn.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ /* $OpenBSD: signal.h,v 1.8 2006/01/09 18:18:37 millert Exp $ */
/*-
* Copyright (c) 1993 /*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@@ -26,29 +30,22 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*
* @(#)signal.h 8.1 (Berkeley) 6/10/93
*/ */
#include <err.h> #ifndef _MIPS_SIGNAL_H_
#include <errno.h> #define _MIPS_SIGNAL_H_
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
extern char *__progname; /* Program name, from crt0. */ #define SC_REGMASK (0*REGSZ)
#define SC_STATUS (1*REGSZ)
void #define SC_PC (2*REGSZ)
_vwarn(const char *fmt, va_list ap) #define SC_REGS (SC_PC+8)
{ #define SC_FPREGS (SC_REGS+32*8)
int sverrno; #define SC_ACX (SC_FPREGS+32*REGSZ_FP)
#define SC_USED_MATH (SC_ACX+3*REGSZ)
sverrno = errno; /* OpenBSD compatibility */
(void)fprintf(stderr, "%s: ", __progname); #define SC_MASK SC_REGMASK
if (fmt != NULL) { #define SC_FPUSED SC_USED_MATH
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, ": ");
}
(void)fprintf(stderr, "%s\n", strerror(sverrno));
}
__weak_alias(vwarn, _vwarn);
#endif /* !_MIPS_SIGNAL_H_ */

View File

@@ -49,7 +49,10 @@ libc_openbsd_src_files_mips64 += \
libc_bionic_src_files_mips64 += \ libc_bionic_src_files_mips64 += \
arch-mips64/bionic/__bionic_clone.S \ arch-mips64/bionic/__bionic_clone.S \
arch-mips64/bionic/_exit_with_stack_teardown.S \ arch-mips64/bionic/_exit_with_stack_teardown.S \
arch-mips64/bionic/__get_sp.S \
arch-mips64/bionic/_setjmp.S \
arch-mips64/bionic/setjmp.S \ arch-mips64/bionic/setjmp.S \
arch-mips64/bionic/sigsetjmp.S \
arch-mips64/bionic/syscall.S \ arch-mips64/bionic/syscall.S \
arch-mips64/bionic/vfork.S \ arch-mips64/bionic/vfork.S \

View File

@@ -1,26 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(__rt_sigqueueinfo)
.set push
.set noreorder
li v0, __NR_rt_sigqueueinfo
syscall
bnez a3, 1f
move a0, v0
j ra
nop
1:
move t0, ra
bal 2f
nop
2:
.cpsetup ra, t1, 2b
LA t9,__set_errno_internal
.cpreturn
j t9
move ra, t0
.set pop
END(__rt_sigqueueinfo)
.hidden __rt_sigqueueinfo

View File

@@ -2,10 +2,10 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(sethostname) ENTRY(_flush_cache)
.set push .set push
.set noreorder .set noreorder
li v0, __NR_sethostname li v0, __NR_cacheflush
syscall syscall
bnez a3, 1f bnez a3, 1f
move a0, v0 move a0, v0
@@ -22,4 +22,4 @@ ENTRY(sethostname)
j t9 j t9
move ra, t0 move ra, t0
.set pop .set pop
END(sethostname) END(_flush_cache)

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(__clock_nanosleep) ENTRY(clock_nanosleep)
.set push .set push
.set noreorder .set noreorder
li v0, __NR_clock_nanosleep li v0, __NR_clock_nanosleep
@@ -22,5 +22,4 @@ ENTRY(__clock_nanosleep)
j t9 j t9
move ra, t0 move ra, t0
.set pop .set pop
END(__clock_nanosleep) END(clock_nanosleep)
.hidden __clock_nanosleep

View File

@@ -65,21 +65,21 @@ name: \
ENTRY (wcslen) ENTRY (wcslen)
mov STR(%esp), %edx mov STR(%esp), %edx
#endif #endif
cmpl $0, (%edx) cmp $0, (%edx)
jz L(exit_tail0) jz L(exit_tail0)
cmpl $0, 4(%edx) cmp $0, 4(%edx)
jz L(exit_tail1) jz L(exit_tail1)
cmpl $0, 8(%edx) cmp $0, 8(%edx)
jz L(exit_tail2) jz L(exit_tail2)
cmpl $0, 12(%edx) cmp $0, 12(%edx)
jz L(exit_tail3) jz L(exit_tail3)
cmpl $0, 16(%edx) cmp $0, 16(%edx)
jz L(exit_tail4) jz L(exit_tail4)
cmpl $0, 20(%edx) cmp $0, 20(%edx)
jz L(exit_tail5) jz L(exit_tail5)
cmpl $0, 24(%edx) cmp $0, 24(%edx)
jz L(exit_tail6) jz L(exit_tail6)
cmpl $0, 28(%edx) cmp $0, 28(%edx)
jz L(exit_tail7) jz L(exit_tail7)
pxor %xmm0, %xmm0 pxor %xmm0, %xmm0

View File

@@ -98,13 +98,13 @@ L(WcscpyAtom):
mov STR2(%esp), %ecx mov STR2(%esp), %ecx
lea (%edi, %eax), %edx lea (%edi, %eax), %edx
cmpl $0, (%ecx) cmp $0, (%ecx)
jz L(Exit4) jz L(Exit4)
cmpl $0, 4(%ecx) cmp $0, 4(%ecx)
jz L(Exit8) jz L(Exit8)
cmpl $0, 8(%ecx) cmp $0, 8(%ecx)
jz L(Exit12) jz L(Exit12)
cmpl $0, 12(%ecx) cmp $0, 12(%ecx)
jz L(Exit16) jz L(Exit16)
#undef RETURN #undef RETURN

View File

@@ -92,13 +92,13 @@ ENTRY (wcscpy)
mov STR1(%esp), %edx mov STR1(%esp), %edx
mov STR2(%esp), %ecx mov STR2(%esp), %ecx
cmpl $0, (%ecx) cmp $0, (%ecx)
jz L(ExitTail4) jz L(ExitTail4)
cmpl $0, 4(%ecx) cmp $0, 4(%ecx)
jz L(ExitTail8) jz L(ExitTail8)
cmpl $0, 8(%ecx) cmp $0, 8(%ecx)
jz L(ExitTail12) jz L(ExitTail12)
cmpl $0, 12(%ecx) cmp $0, 12(%ecx)
jz L(ExitTail16) jz L(ExitTail16)
PUSH (%edi) PUSH (%edi)

View File

@@ -1,7 +1,10 @@
/* $OpenBSD: verr.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ /* $OpenBSD: _setjmp.S,v 1.5 2005/08/07 11:30:38 espie Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1990 The Regents of the University of California.
* The Regents of the University of California. All rights reserved. * All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -28,29 +31,43 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <err.h> #include <private/bionic_asm.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
extern char *__progname; /* Program name, from crt0. */ /*
* C library -- _setjmp, _longjmp
*
* _longjmp(a,v)
* will generate a "return(v)" from the last call to
* _setjmp(a)
* by restoring registers from the stack.
* The previous signal state is NOT restored.
*/
__dead void ENTRY(_setjmp)
_verr(int eval, const char *fmt, va_list ap) movl 4(%esp),%eax
{ movl 0(%esp),%edx
int sverrno; movl %edx, 0(%eax) /* rta */
movl %ebx, 4(%eax)
sverrno = errno; movl %esp, 8(%eax)
(void)fprintf(stderr, "%s: ", __progname); movl %ebp,12(%eax)
if (fmt != NULL) { movl %esi,16(%eax)
(void)vfprintf(stderr, fmt, ap); movl %edi,20(%eax)
(void)fprintf(stderr, ": "); xorl %eax,%eax
} ret
(void)fprintf(stderr, "%s\n", strerror(sverrno)); END(_setjmp)
exit(eval);
}
__weak_alias(verr, _verr);
ENTRY(_longjmp)
movl 4(%esp),%edx
movl 8(%esp),%eax
movl 0(%edx),%ecx
movl 4(%edx),%ebx
movl 8(%edx),%esp
movl 12(%edx),%ebp
movl 16(%edx),%esi
movl 20(%edx),%edi
testl %eax,%eax
jnz 1f
incl %eax
1: movl %ecx,0(%esp)
ret
END(_longjmp)

View File

@@ -1,3 +1,4 @@
/* $OpenBSD: setjmp.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
/*- /*-
* Copyright (c) 1990 The Regents of the University of California. * Copyright (c) 1990 The Regents of the University of California.
* All rights reserved. * All rights reserved.
@@ -32,98 +33,55 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
#define _JB_EDX 0 /*
#define _JB_EBX 1 * C library -- setjmp, longjmp
#define _JB_ESP 2 *
#define _JB_EBP 3 * longjmp(a,v)
#define _JB_ESI 4 * will generate a "return(v)" from the last call to
#define _JB_EDI 5 * setjmp(a)
#define _JB_SIGMASK 6 * by restoring registers from the stack.
#define _JB_SIGFLAG 7 * The previous signal state is restored.
*/
ENTRY(setjmp) ENTRY(setjmp)
movl 4(%esp),%ecx
movl $1,(_JB_SIGFLAG * 4)(%ecx)
jmp .L_sigsetjmp_signal_mask
END(setjmp)
ENTRY(_setjmp)
movl 4(%esp),%ecx
movl $0,(_JB_SIGFLAG * 4)(%ecx)
jmp .L_sigsetjmp_no_signal_mask
END(_setjmp)
ENTRY(sigsetjmp)
movl 4(%esp),%ecx
movl 8(%esp),%eax
// Record whether or not the signal mask is valid.
movl %eax,(_JB_SIGFLAG * 4)(%ecx)
// Do we need to save the signal mask?
testl %eax,%eax
jz 1f
.L_sigsetjmp_signal_mask:
// Get the current signal mask.
PIC_PROLOGUE PIC_PROLOGUE
pushl $0 pushl $0
call PIC_PLT(sigblock) call PIC_PLT(sigblock)
addl $4,%esp addl $4,%esp
PIC_EPILOGUE PIC_EPILOGUE
// Save the signal mask.
movl 4(%esp),%ecx movl 4(%esp),%ecx
movl %eax,(_JB_SIGMASK * 4)(%ecx)
.L_sigsetjmp_no_signal_mask:
1:
// Save the callee-save registers.
movl 0(%esp),%edx movl 0(%esp),%edx
movl %edx,(_JB_EDX * 4)(%ecx) movl %edx, 0(%ecx)
movl %ebx,(_JB_EBX * 4)(%ecx) movl %ebx, 4(%ecx)
movl %esp,(_JB_ESP * 4)(%ecx) movl %esp, 8(%ecx)
movl %ebp,(_JB_EBP * 4)(%ecx) movl %ebp,12(%ecx)
movl %esi,(_JB_ESI * 4)(%ecx) movl %esi,16(%ecx)
movl %edi,(_JB_EDI * 4)(%ecx) movl %edi,20(%ecx)
movl %eax,24(%ecx)
xorl %eax,%eax xorl %eax,%eax
ret ret
END(sigsetjmp) END(setjmp)
ENTRY(siglongjmp) ENTRY(longjmp)
// Do we have a signal mask to restore?
movl 4(%esp),%edx movl 4(%esp),%edx
cmpl $0,(_JB_SIGFLAG * 4)(%edx)
jz 1f
// Restore the signal mask.
PIC_PROLOGUE PIC_PROLOGUE
pushl (_JB_SIGMASK * 4)(%edx) pushl 24(%edx)
call PIC_PLT(sigsetmask) call PIC_PLT(sigsetmask)
addl $4,%esp addl $4,%esp
PIC_EPILOGUE PIC_EPILOGUE
1:
// Restore the callee-save registers.
movl 4(%esp),%edx movl 4(%esp),%edx
movl 8(%esp),%eax movl 8(%esp),%eax
movl (_JB_EDX * 4)(%edx),%ecx movl 0(%edx),%ecx
movl (_JB_EBX * 4)(%edx),%ebx movl 4(%edx),%ebx
movl (_JB_ESP * 4)(%edx),%esp movl 8(%edx),%esp
movl (_JB_EBP * 4)(%edx),%ebp movl 12(%edx),%ebp
movl (_JB_ESI * 4)(%edx),%esi movl 16(%edx),%esi
movl (_JB_EDI * 4)(%edx),%edi movl 20(%edx),%edi
testl %eax,%eax testl %eax,%eax
jnz 2f jnz 1f
incl %eax incl %eax
2: 1: movl %ecx,0(%esp)
movl %ecx,0(%esp)
ret ret
END(siglongjmp) END(longjmp)
.globl longjmp
.equ longjmp, siglongjmp
.globl _longjmp
.equ _longjmp, siglongjmp

View File

@@ -0,0 +1,86 @@
/* $OpenBSD: sigsetjmp.S,v 1.7 2005/08/07 11:30:38 espie Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
#include <private/bionic_asm.h>
ENTRY(sigsetjmp)
movl 4(%esp),%ecx
movl 8(%esp),%eax
movl %eax,28(%ecx)
testl %eax,%eax
jz 1f
PIC_PROLOGUE
pushl $0
call PIC_PLT(sigblock)
addl $4,%esp
PIC_EPILOGUE
movl 4(%esp),%ecx
movl %eax,24(%ecx)
1: movl 0(%esp),%edx
movl %edx, 0(%ecx)
movl %ebx, 4(%ecx)
movl %esp, 8(%ecx)
movl %ebp,12(%ecx)
movl %esi,16(%ecx)
movl %edi,20(%ecx)
xorl %eax,%eax
ret
END(sigsetjmp)
ENTRY(siglongjmp)
movl 4(%esp),%edx
cmpl $0,28(%edx)
jz 1f
PIC_PROLOGUE
pushl 24(%edx)
call PIC_PLT(sigsetmask)
addl $4,%esp
PIC_EPILOGUE
1: movl 4(%esp),%edx
movl 8(%esp),%eax
movl 0(%edx),%ecx
movl 4(%edx),%ebx
movl 8(%edx),%esp
movl 12(%edx),%ebp
movl 16(%edx),%esi
movl 20(%edx),%edi
testl %eax,%eax
jnz 2f
incl %eax
2: movl %ecx,0(%esp)
ret
END(siglongjmp)

View File

@@ -49,6 +49,15 @@
#define PIC_GOT(x) x@GOT(%ebx) #define PIC_GOT(x) x@GOT(%ebx)
#define PIC_GOTOFF(x) x@GOTOFF(%ebx) #define PIC_GOTOFF(x) x@GOTOFF(%ebx)
#define __bionic_asm_align 16 /* let kernels and others override entrypoint alignment */
#if !defined(_ALIGN_TEXT) && !defined(_KERNEL)
# ifdef _STANDALONE
# define _ALIGN_TEXT .align 1
# elif defined __ELF__
# define _ALIGN_TEXT .align 16
# else
# define _ALIGN_TEXT .align 4
# endif
#endif
#endif /* !_I386_ASM_H_ */ #endif /* !_I386_ASM_H_ */

View File

@@ -0,0 +1,61 @@
/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*/
#ifndef _MACHINE_ENDIAN_H_
#define _MACHINE_ENDIAN_H_
#ifdef __GNUC__
#define __swap32md(x) __statement({ \
uint32_t __swap32md_x = (x); \
\
__asm ("bswap %0" : "+r" (__swap32md_x)); \
__swap32md_x; \
})
#define __swap64md(x) __statement({ \
uint64_t __swap64md_x = (x); \
\
(uint64_t)__swap32md(__swap64md_x >> 32) | \
(uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
})
#define __swap16md(x) __statement({ \
uint16_t __swap16md_x = (x); \
\
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
__swap16md_x; \
})
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define MD_SWAP
#endif /* __GNUC__ */
#define _BYTE_ORDER _LITTLE_ENDIAN
#include <sys/types.h>
#include <sys/endian.h>
#endif /* _MACHINE_ENDIAN_H_ */

View File

@@ -0,0 +1,51 @@
/* $OpenBSD: exec.h,v 1.9 2003/04/17 03:42:14 drahn Exp $ */
/* $NetBSD: exec.h,v 1.6 1994/10/27 04:16:05 cgd Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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 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.
*/
#ifndef _I386_EXEC_H_
#define _I386_EXEC_H_
#define __LDPGSZ 4096
#define NATIVE_EXEC_ELF
#define ARCH_ELFSIZE 32
#define ELF_TARG_CLASS ELFCLASS32
#define ELF_TARG_DATA ELFDATA2LSB
#define ELF_TARG_MACH EM_386 /* XXX - EM_486 is currently unused
by all OSs/compilers/linkers */
#define _NLIST_DO_AOUT
#define _NLIST_DO_ELF
#define _KERN_DO_AOUT
#define _KERN_DO_ELF
#endif /* _I386_EXEC_H_ */

View File

@@ -1,31 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(__rt_sigqueueinfo)
pushl %ebx
.cfi_def_cfa_offset 8
.cfi_rel_offset ebx, 0
pushl %ecx
.cfi_adjust_cfa_offset 4
.cfi_rel_offset ecx, 0
pushl %edx
.cfi_adjust_cfa_offset 4
.cfi_rel_offset edx, 0
mov 16(%esp), %ebx
mov 20(%esp), %ecx
mov 24(%esp), %edx
movl $__NR_rt_sigqueueinfo, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno_internal
addl $4, %esp
1:
popl %edx
popl %ecx
popl %ebx
ret
END(__rt_sigqueueinfo)

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
ENTRY(__clock_nanosleep) ENTRY(clock_nanosleep)
pushl %ebx pushl %ebx
.cfi_def_cfa_offset 8 .cfi_def_cfa_offset 8
.cfi_rel_offset ebx, 0 .cfi_rel_offset ebx, 0
@@ -33,4 +33,4 @@ ENTRY(__clock_nanosleep)
popl %ecx popl %ecx
popl %ebx popl %ebx
ret ret
END(__clock_nanosleep) END(clock_nanosleep)

View File

@@ -1,26 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(sethostname)
pushl %ebx
.cfi_def_cfa_offset 8
.cfi_rel_offset ebx, 0
pushl %ecx
.cfi_adjust_cfa_offset 4
.cfi_rel_offset ecx, 0
mov 12(%esp), %ebx
mov 16(%esp), %ecx
movl $__NR_sethostname, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno_internal
addl $4, %esp
1:
popl %ecx
popl %ebx
ret
END(sethostname)

View File

@@ -40,8 +40,10 @@ libc_bionic_src_files_x86 += \
arch-x86/bionic/_exit_with_stack_teardown.S \ arch-x86/bionic/_exit_with_stack_teardown.S \
arch-x86/bionic/libgcc_compat.c \ arch-x86/bionic/libgcc_compat.c \
arch-x86/bionic/__restore.S \ arch-x86/bionic/__restore.S \
arch-x86/bionic/_setjmp.S \
arch-x86/bionic/setjmp.S \ arch-x86/bionic/setjmp.S \
arch-x86/bionic/__set_tls.c \ arch-x86/bionic/__set_tls.c \
arch-x86/bionic/sigsetjmp.S \
arch-x86/bionic/syscall.S \ arch-x86/bionic/syscall.S \
arch-x86/bionic/vfork.S \ arch-x86/bionic/vfork.S \

View File

@@ -0,0 +1,83 @@
/* $OpenBSD: _setjmp.S,v 1.1 2004/01/28 01:44:45 mickey Exp $ */
/* $NetBSD: _setjmp.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#include <private/bionic_asm.h>
#include <machine/setjmp.h>
/*
* C library -- _setjmp, _longjmp
*
* _longjmp(a,v)
* will generate a "return(v)" from the last call to
* _setjmp(a)
* by restoring registers from the stack.
* The previous signal state is NOT restored.
*/
ENTRY(_setjmp)
movq (%rsp),%r11
movq %rbx,(_JB_RBX * 8)(%rdi)
movq %rbp,(_JB_RBP * 8)(%rdi)
movq %r12,(_JB_R12 * 8)(%rdi)
movq %r13,(_JB_R13 * 8)(%rdi)
movq %r14,(_JB_R14 * 8)(%rdi)
movq %r15,(_JB_R15 * 8)(%rdi)
movq %rsp,(_JB_RSP * 8)(%rdi)
movq %r11,(_JB_PC * 8)(%rdi)
xorl %eax,%eax
ret
END(_setjmp)
ENTRY(_longjmp)
movq (_JB_RBX * 8)(%rdi),%rbx
movq (_JB_RBP * 8)(%rdi),%rbp
movq (_JB_R12 * 8)(%rdi),%r12
movq (_JB_R13 * 8)(%rdi),%r13
movq (_JB_R14 * 8)(%rdi),%r14
movq (_JB_R15 * 8)(%rdi),%r15
movq (_JB_RSP * 8)(%rdi),%rsp
movq (_JB_PC * 8)(%rdi),%r11
movl %esi,%eax
testl %eax,%eax
jnz 1f
incl %eax
1: movq %r11,0(%rsp)
ret
END(_longjmp)

View File

@@ -1,3 +1,6 @@
/* $OpenBSD: setjmp.S,v 1.3 2012/08/22 17:19:34 pascal Exp $ */
/* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
/* /*
* Copyright (c) 2001 Wasabi Systems, Inc. * Copyright (c) 2001 Wasabi Systems, Inc.
* All rights reserved. * All rights reserved.
@@ -34,51 +37,25 @@
*/ */
#include <private/bionic_asm.h> #include <private/bionic_asm.h>
#include <machine/setjmp.h>
// These are only the callee-saved registers. Code calling setjmp /*
// will expect the rest to be clobbered anyway. * C library -- _setjmp, _longjmp
*
#define _JB_RBX 0 * longjmp(a,v)
#define _JB_RBP 1 * will generate a "return(v)" from the last call to
#define _JB_R12 2 * setjmp(a)
#define _JB_R13 3 * by restoring registers from the stack.
#define _JB_R14 4 * The previous signal state is restored.
#define _JB_R15 5 */
#define _JB_RSP 6
#define _JB_PC 7
#define _JB_SIGFLAG 8
#define _JB_SIGMASK 9
#define _JB_SIGMASK_RT 10 // sigprocmask will write here too.
ENTRY(setjmp) ENTRY(setjmp)
movl $1,%esi pushq %rdi
jmp PIC_PLT(sigsetjmp) xorq %rdi,%rdi
END(setjmp) call PIC_PLT(sigblock)
popq %rdi
movq %rax,(_JB_SIGMASK * 8)(%rdi)
ENTRY(_setjmp)
movl $0,%esi
jmp PIC_PLT(sigsetjmp)
END(_setjmp)
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
ENTRY(sigsetjmp)
// Record whether or not we're saving the signal mask.
movl %esi,(_JB_SIGFLAG * 8)(%rdi)
// Do we need to save the signal mask?
testl %esi,%esi
jz 2f
// Save current signal mask.
pushq %rdi // Push 'env'.
// The 'how' argument is ignored if new_mask is NULL.
xorq %rsi,%rsi // NULL.
leaq (_JB_SIGMASK * 8)(%rdi),%rdx // old_mask.
call PIC_PLT(sigprocmask)
popq %rdi // Pop 'env'.
2:
// Save the callee-save registers.
movq (%rsp),%r11 movq (%rsp),%r11
movq %rbx,(_JB_RBX * 8)(%rdi) movq %rbx,(_JB_RBX * 8)(%rdi)
movq %rbp,(_JB_RBP * 8)(%rdi) movq %rbp,(_JB_RBP * 8)(%rdi)
@@ -89,29 +66,18 @@ ENTRY(sigsetjmp)
movq %rsp,(_JB_RSP * 8)(%rdi) movq %rsp,(_JB_RSP * 8)(%rdi)
movq %r11,(_JB_PC * 8)(%rdi) movq %r11,(_JB_PC * 8)(%rdi)
xorl %eax,%eax 2: xorl %eax,%eax
ret ret
END(sigsetjmp) END(setjmp)
// void siglongjmp(sigjmp_buf env, int value); ENTRY(longjmp)
ENTRY(siglongjmp)
movq %rdi,%r12 movq %rdi,%r12
pushq %rsi // Push 'value'. movl %esi,%r8d
// Do we need to restore the signal mask? movq (_JB_SIGMASK * 8)(%rdi),%rdi
cmpl $0,(_JB_SIGFLAG * 8)(%rdi) pushq %r8
jz 2f call PIC_PLT(sigsetmask)
popq %r8
// Restore the signal mask.
movq $2,%rdi // SIG_SETMASK.
leaq (_JB_SIGMASK * 8)(%r12),%rsi // new_mask.
xorq %rdx,%rdx // NULL.
call PIC_PLT(sigprocmask)
2:
popq %rax // Pop 'value'.
// Restore the callee-save registers.
movq (_JB_RBX * 8)(%r12),%rbx movq (_JB_RBX * 8)(%r12),%rbx
movq (_JB_RBP * 8)(%r12),%rbp movq (_JB_RBP * 8)(%r12),%rbp
movq (_JB_R13 * 8)(%r12),%r13 movq (_JB_R13 * 8)(%r12),%r13
@@ -121,15 +87,10 @@ ENTRY(siglongjmp)
movq (_JB_PC * 8)(%r12),%r11 movq (_JB_PC * 8)(%r12),%r11
movq (_JB_R12 * 8)(%r12),%r12 movq (_JB_R12 * 8)(%r12),%r12
movl %r8d,%eax
testl %eax,%eax testl %eax,%eax
jnz 1f jnz 1f
incl %eax incl %eax
1: 1: movq %r11,0(%rsp)
movq %r11,0(%rsp)
ret ret
END(siglongjmp) END(longjmp)
.globl longjmp
.equ longjmp, siglongjmp
.globl _longjmp
.equ _longjmp, siglongjmp

View File

@@ -0,0 +1,101 @@
/* $OpenBSD: sigsetjmp.S,v 1.3 2012/08/22 17:19:34 pascal Exp $ */
/* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#include <private/bionic_asm.h>
#include <machine/setjmp.h>
/*
* C library -- _setjmp, _longjmp
*
* longjmp(a,v)
* will generate a "return(v)" from the last call to
* setjmp(a)
* by restoring registers from the stack.
* The previous signal state is restored.
*/
ENTRY(sigsetjmp)
movl %esi,(_JB_SIGFLAG * 8)(%rdi)
testl %esi,%esi
jz 2f
pushq %rdi
xorq %rdi,%rdi
call PIC_PLT(sigblock)
popq %rdi
movq %rax,(_JB_SIGMASK * 8)(%rdi)
2: movq (%rsp),%r11
movq %rbx,(_JB_RBX * 8)(%rdi)
movq %rbp,(_JB_RBP * 8)(%rdi)
movq %r12,(_JB_R12 * 8)(%rdi)
movq %r13,(_JB_R13 * 8)(%rdi)
movq %r14,(_JB_R14 * 8)(%rdi)
movq %r15,(_JB_R15 * 8)(%rdi)
movq %rsp,(_JB_RSP * 8)(%rdi)
movq %r11,(_JB_PC * 8)(%rdi)
2: xorl %eax,%eax
ret
END(sigsetjmp)
ENTRY(siglongjmp)
movq %rdi,%r12
pushq %rsi
cmpl $0, (_JB_SIGFLAG * 8)(%rdi)
jz 2f
movq (_JB_SIGMASK * 8)(%rdi),%rdi
call PIC_PLT(sigsetmask)
2: popq %rax
movq (_JB_RBX * 8)(%r12),%rbx
movq (_JB_RBP * 8)(%r12),%rbp
movq (_JB_R13 * 8)(%r12),%r13
movq (_JB_R14 * 8)(%r12),%r14
movq (_JB_R15 * 8)(%r12),%r15
movq (_JB_RSP * 8)(%r12),%rsp
movq (_JB_PC * 8)(%r12),%r11
movq (_JB_R12 * 8)(%r12),%r12
testl %eax,%eax
jnz 1f
incl %eax
1: movq %r11,0(%rsp)
ret
END(siglongjmp)

View File

@@ -40,6 +40,13 @@
#define PIC_PLT(x) x@PLT #define PIC_PLT(x) x@PLT
#define PIC_GOT(x) x@GOTPCREL(%rip) #define PIC_GOT(x) x@GOTPCREL(%rip)
#define __bionic_asm_align 16 /* let kernels and others override entrypoint alignment */
#ifndef _ALIGN_TEXT
# ifdef _STANDALONE
# define _ALIGN_TEXT .align 4
# else
# define _ALIGN_TEXT .align 16
# endif
#endif
#endif /* !_AMD64_ASM_H_ */ #endif /* !_AMD64_ASM_H_ */

View File

@@ -0,0 +1,61 @@
/* $OpenBSD: endian.h,v 1.5 2011/03/12 22:27:48 guenther Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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.
*
* 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.
*/
#ifndef _MACHINE_ENDIAN_H_
#define _MACHINE_ENDIAN_H_
#ifdef __GNUC__
#define __swap32md(x) __statement({ \
u_int32_t __swap32md_x = (x); \
\
__asm ("bswap %0" : "+r" (__swap32md_x)); \
__swap32md_x; \
})
#define __swap64md(x) __statement({ \
u_int64_t __swap64md_x = (x); \
\
__asm ("bswapq %0" : "+r" (__swap64md_x)); \
__swap64md_x; \
})
#define __swap16md(x) __statement({ \
u_int16_t __swap16md_x = (x); \
\
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
__swap16md_x; \
})
/* Tell sys/endian.h we have MD variants of the swap macros. */
#define MD_SWAP
#endif /* __GNUC__ */
#define _BYTE_ORDER _LITTLE_ENDIAN
#include <sys/endian.h>
#endif /* _MACHINE_ENDIAN_H_ */

View File

@@ -0,0 +1,20 @@
/* $OpenBSD: exec.h,v 1.4 2012/09/11 15:44:17 deraadt Exp $ */
/*
* Written by Artur Grabowski <art@openbsd.org> Public Domain
*/
#ifndef _MACHINE_EXEC_H_
#define _MACHINE_EXEC_H_
#define __LDPGSZ 4096
#define ARCH_ELFSIZE 64
#define ELF_TARG_CLASS ELFCLASS64
#define ELF_TARG_DATA ELFDATA2LSB
#define ELF_TARG_MACH EM_X86_64
#define _NLIST_DO_ELF
#define _KERN_DO_ELF64
#endif

View File

@@ -1,4 +1,21 @@
/* $OpenBSD: setjmp.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */ /* $OpenBSD: setjmp.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
/* $NetBSD: setjmp.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */ /* $NetBSD: setjmp.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */
/*
* machine/setjmp.h: machine dependent setjmp-related information.
* These are only the callee-saved registers, code calling setjmp
* will expect the rest to be clobbered anyway.
*/
#define _JB_RBX 0
#define _JB_RBP 1
#define _JB_R12 2
#define _JB_R13 3
#define _JB_R14 4
#define _JB_R15 5
#define _JB_RSP 6
#define _JB_PC 7
#define _JB_SIGFLAG 8
#define _JB_SIGMASK 9
#define _JBLEN 11 /* size, in longs, of a jmp_buf */ #define _JBLEN 11 /* size, in longs, of a jmp_buf */

Some files were not shown because too many files have changed in this diff Show More