Commit Graph

32 Commits

Author SHA1 Message Date
Siva Chandra Reddy 3f965818b6 [libc] Add POSIX execv and execve functions.
The POSIX global variable environ has also been added.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D135351
2022-10-06 19:50:23 +00:00
Michael Jones 1801c356f6 [libc] add syscall function
Add the syscall wrapper function and tests. It's implemented using a
macro to guarantee the minimum number of arguments.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D134919
2022-09-30 15:46:28 -07:00
Siva Chandra 8856137ce7 [libc] Enable a few entrypoints on aarch64 which are now available on x86_64. 2022-08-23 12:31:42 -07:00
Siva Chandra Reddy 4d97766316 [libc] Install startup files with the install-libc target.
Differential Revision: https://reviews.llvm.org/D132212
2022-08-19 20:15:16 +00:00
Siva Chandra Reddy 0071a79532 [libc] Add implementation of pthread_exit and thrd_exit.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D131451
2022-08-10 06:28:47 +00:00
Siva Chandra Reddy c6dcc359ac [libc] Add __cxa_atexit support to the atexit function.
Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D131219
2022-08-09 21:42:41 +00:00
Siva Chandra c9e1ecd46d [libc] Adjust aarch64 startup code to reliably sniff out the start args.
Since this now allows, the init/fini array iteration has been added in
a similar fashion to x86_64 and the corresponding test enabled.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D131133
2022-08-03 23:12:02 -07:00
Siva Chandra Reddy f23076f6c5 [libc] Add init and fini array iteration to the loader.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D130966
2022-08-03 17:53:23 +00:00
Siva Chandra 98fdabecf5 [libc] Enable a few stdlib and time functions on aarch64. 2022-07-14 14:37:50 -07:00
Siva Chandra Reddy 8dc42802f7 [libc] Add implementations of pthread_equal and pthread_self.
Reviewed By: michaelrj, lntue

Differential Revision: https://reviews.llvm.org/D129729
2022-07-14 20:12:35 +00:00
Siva Chandra Reddy 859c189727 [libc] Linux threads - Setup TLS area of a new thread and cleanup at exit.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D129543
2022-07-13 20:46:18 +00:00
Siva Chandra be6af89f85 [libc] Add TLS image initialization to aarch64 startup code.
The TLS loader test has been enabled for aarch64.
Handling of PT_TLS' filesz and memsz for x86_64 has also been fixed.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D128032
2022-06-17 22:50:14 -07:00
Siva Chandra Reddy 107ce71849 [libc] Use real objects and archives in integration tests.
Previously, we used empty, non-ELF crti.o, crtn.o, libm.a and libc++.a
files. Instead, we now still use dummies but they are real ELF object
files and archives.
2022-03-24 07:02:33 +00:00
Siva Chandra Reddy 7fdb50c813 [libc] Add a new rule add_integration_test.
All existing loader tests are switched to an integration test added with
the new rule. Also, the getenv test is now enabled as an integration test.

All loader tests have been moved to test/integration. Also, the simple
checker library for the previous loader tests has been moved to a
separate directory of its own.

A follow up change will perform more cleanup of the loader CMake rules
to eliminate now redundent options.

Reviewed By: lntue, michaelrj

Differential Revision: https://reviews.llvm.org/D122266
2022-03-23 20:57:29 +00:00
Siva Chandra Reddy b950a0d44d [libc][Obvious] Remove an unnecessary dep and use inline_memcpy.
An unnecessary dep of the getenv function is removed. From the x86_64
loader, a call to __llvm_libc::memcpy is replaced with call to
__llvm_libc::inline_memcpy.
2022-03-22 07:08:57 +00:00
Siva Chandra Reddy fe2cc14ad4 [libc] Align the stack pointer in the start function.
The loader TLS test for x86_64, which now passes, has been enabled.
A future change should enable the test for aarch64 as well.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D121091
2022-03-07 19:45:53 +00:00
Siva Chandra Reddy c74c344263 [libc] Fix alignment logic in TLS image size calculation. 2022-03-07 09:21:37 +00:00
Siva Chandra Reddy 86bebe1a90 [lib][Obvious] Fix style in a few include directives. 2022-02-16 05:57:12 +00:00
Jeff Bailey 55120aad4e Implement basic loader for Linux aarch64
This implements a basic arm64 loader for Linux, and all the currently
enabled linker tests pass.  TLS is not implemented, and functions
using it will have undefined behaviour.  Notably, the TLS test is
currently disabled on x86_64.

Much of the structure is copied from x86_64 to allow for a refactoring
of the start code between architectures.

Tested:
ninja libc_loader_tests on aarch64-linux.

Co-authored-by: Raman Tenneti <rtenneti@google.com>

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119641
2022-02-16 03:42:44 +00:00
Raman Tenneti f2a7f83595 Introduce getenv to LLVM libc
Add support for getenv as defined by the Open Group's "System Interface &
 Header" in https://pubs.opengroup.org/onlinepubs/7908799/xsh/getenv.html

getenv requires a standard way of accessing the environment,
so a pointer to the environment is added to the startup in crt1.
Consquently, this function is not usable on top of other libcs.

Added starts_with method to StringView. getenv function uses it.

Co-authored-by: Jeff Bailey <jeffbailey@google.com>

Reviewed By: sivachandra, rtenneti

Differential Revision: https://reviews.llvm.org/D119403
2022-02-14 10:10:13 -08:00
Siva Chandra Reddy 134e9d1914 [libc][NFC] Move sys/mman entrypoints to the default build configs.
Specifically, mmap and munmap have been moved to the default build list
of entrypoints. To support this, certain deps and includes have been
adjusted. The use of errno in some cases has been updated.
2022-01-11 16:51:10 +00:00
Siva Chandra Reddy 3cc2161c89 [libc] Move the x86_64 syscall functions to OSUtil.
Reviewed By: michaelrj, lntue

Differential Revision: https://reviews.llvm.org/D116177
2021-12-22 21:48:57 +00:00
Guillaume Chatelet 7c2ece523d [libc] Normalize LIBC_TARGET_MACHINE
Current implementation defines LIBC_TARGET_MACHINE with the use of CMAKE_SYSTEM_PROCESSOR.
Unfortunately CMAKE_SYSTEM_PROCESSOR is OS dependent and can produce different results.
An evidence of this is the various matchers used to detect whether the architecture is x86.

This patch normalizes LIBC_TARGET_MACHINE and renames it LIBC_TARGET_ARCHITECTURE.
I've added many architectures but we may want to limit ourselves to x86 and ARM.

Differential Revision: https://reviews.llvm.org/D101524
2021-05-05 15:52:42 +00:00
Siva Chandra Reddy 5d59385ba6 [libc] Setup TLS in x86_64 loader.
The new code added is still very x86_64 specific. AArch64 support will
be added very soon and refactoring of the loader code will be done as
part of the patches adding it.

Reviewed By: asteinhauser

Differential Revision: https://reviews.llvm.org/D82700
2020-08-07 23:19:03 -07:00
Siva Chandra Reddy fd3295fb6f [libc] Skip entrypoints not present in the entrypoints list.
Summary:
If a test depends on a skipped entrypoint, then the test is also
skipped. This setup will be useful as we gradually add support for
more operating systems and target architectures.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D81489
2020-06-09 14:40:28 -07:00
Siva Chandra Reddy 7f12512db2 [libc][Take 2] Propagate entrypoint deps to downstream targets.
This reverts commit a8086ba4ac.
Setting couple of target properties to an empty string was missed in the
previous commit.
2020-04-21 10:29:09 -07:00
Siva Chandra Reddy a8086ba4ac [libc] Revert "Propagate entrypoint deps to downstream targets."
This reverts commit 20cb440ea2 as the
target llvmlibc seems to be failing on the bots.
2020-04-21 10:10:18 -07:00
Siva Chandra Reddy 20cb440ea2 [libc] Propagate entrypoint deps to downstream targets.
Deps are recrusively evaluated at the place they are needed. With this
change, one does not have to list recursive deps of entrypoints when
listing test targets. One will still have to explicitly list all
entrypoint objects when setting up an "add_entrypoint_library" target.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D78537
2020-04-21 09:58:55 -07:00
Siva Chandra Reddy e4767a6f14 [libc] Add fully-qualified target names.
Only targets setup by the special LLVM libc rules now have fully
qualified names. The naming style is similar to fully qualified names in
Python.

Reviewers: abrachet, PaulkaToast, phosek

Differential Revision: https://reviews.llvm.org/D77340
2020-04-10 18:01:52 -07:00
Paula Toth 66d00feb18 [libc][NFC] Make all top of file comments consistent.
Summary:
Made all header files consistent based of this documentation: https://llvm.org/docs/CodingStandards.html#file-headers.
And did the same for all source files top of file comments.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77533
2020-04-08 10:18:37 -07:00
Siva Chandra Reddy 51b899c846 [libc] Extend add_object rule to handle helper object libraries.
The rule is now called add_object_library.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76826
2020-03-28 00:07:46 -07:00
Siva Chandra Reddy f6ccb4fef2 [libc] Add a simple x86_64 linux loader.
This adds a very simple loader. This will be extended to a full loader
in future patches. A utility rule to add unittests has been added to
serve us while we are building out the full loader.

Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D76412
2020-03-25 10:12:35 -07:00