Merge "libm: sync with upstream FreeBSD." into main
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index a8c70e5..182de17 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -65,7 +65,7 @@
int tgkill(pid_t tgid, pid_t tid, int sig) all
void* __brk:brk(void*) all
-int __execve:execve(const char*, char* const*, char* const*) all
+int execve(const char*, char* const*, char* const*) all
int __ptrace:ptrace(int request, int pid, void* addr, void* data) all
# <sys/resource.h>
@@ -330,7 +330,7 @@
int __eventfd:eventfd2(unsigned int, int) all
-void __exit_group:exit_group(int) all
+void _exit|_Exit:exit_group(int) all
void __exit:exit(int) all
int inotify_init1(int) all
diff --git a/libc/bionic/exec.cpp b/libc/bionic/exec.cpp
index 863aa97..56544d0 100644
--- a/libc/bionic/exec.cpp
+++ b/libc/bionic/exec.cpp
@@ -41,10 +41,8 @@
#include "private/FdPath.h"
#include "private/__bionic_get_shell_path.h"
-#include "pthread_internal.h"
extern "C" char** environ;
-extern "C" int __execve(const char* pathname, char* const* argv, char* const* envp);
enum { ExecL, ExecLE, ExecLP };
@@ -183,8 +181,3 @@
if (errno == ENOENT) errno = EBADF;
return -1;
}
-
-__attribute__((no_sanitize("memtag"))) int execve(const char* pathname, char* const* argv,
- char* const* envp) {
- return __execve(pathname, argv, envp);
-}
diff --git a/libc/bionic/exit.cpp b/libc/bionic/exit.cpp
index 04baac2..a5aed78 100644
--- a/libc/bionic/exit.cpp
+++ b/libc/bionic/exit.cpp
@@ -30,17 +30,9 @@
#include <unistd.h>
#include "private/bionic_defs.h"
-#include "pthread_internal.h"
extern "C" void __cxa_finalize(void* dso_handle);
extern "C" void __cxa_thread_finalize();
-extern "C" __noreturn void __exit_group(int status);
-
-__attribute__((no_sanitize("memtag"))) void _exit(int status) {
- __exit_group(status);
-}
-
-__strong_alias(_Exit, _exit);
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
void exit(int status) {
diff --git a/libm/significandl.c b/libm/significandl.c
index c5d7dd4..b672110 100644
--- a/libm/significandl.c
+++ b/libm/significandl.c
@@ -22,11 +22,13 @@
* 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 <math.h>
+// This function is only in glibc.
+// musl and NetBSD/OpenBSD just have the double and float variants,
+// while FreeBSD and iOS/macOS have none.
long double significandl(long double x) {
return scalbnl(x, -ilogbl(x));
}
diff --git a/linker/Android.bp b/linker/Android.bp
index 694d1f5..563cf3d 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -14,6 +14,16 @@
],
}
+linker_common_flags = [
+ "-fno-stack-protector",
+ "-Wstrict-overflow=5",
+ "-fvisibility=hidden",
+ "-Wall",
+ "-Wextra",
+ "-Wunused",
+ "-Werror",
+]
+
// ========================================================
// linker_wrapper - Linux Bionic (on the host)
// ========================================================
@@ -36,15 +46,7 @@
},
},
- cflags: [
- "-fno-stack-protector",
- "-Wstrict-overflow=5",
- "-fvisibility=hidden",
- "-Wall",
- "-Wextra",
- "-Wno-unused",
- "-Werror",
- ],
+ cflags: linker_common_flags,
srcs: [
"linker_wrapper.cpp",
@@ -83,26 +85,8 @@
},
},
- cflags: [
- "-fno-stack-protector",
- "-Wstrict-overflow=5",
- "-fvisibility=hidden",
- "-Wall",
- "-Wextra",
- "-Wunused",
- "-Werror",
- ],
-
- // TODO: split out the asflags.
- asflags: [
- "-fno-stack-protector",
- "-Wstrict-overflow=5",
- "-fvisibility=hidden",
- "-Wall",
- "-Wextra",
- "-Wunused",
- "-Werror",
- ],
+ cflags: linker_common_flags,
+ asflags: linker_common_flags,
product_variables: {
debuggable: {
diff --git a/linker/linker_debug.cpp b/linker/linker_debug.cpp
index b0aae79..e6211f7 100644
--- a/linker/linker_debug.cpp
+++ b/linker/linker_debug.cpp
@@ -30,13 +30,14 @@
#include <unistd.h>
-void linker_log_va_list(int prio __unused, const char* fmt, va_list ap) {
-#if LINKER_DEBUG_TO_LOG
- async_safe_format_log_va_list(5 - prio, "linker", fmt, ap);
-#else
- async_safe_format_fd_va_list(STDOUT_FILENO, fmt, ap);
- write(STDOUT_FILENO, "\n", 1);
-#endif
+void linker_log_va_list(int prio, const char* fmt, va_list ap) {
+ va_list ap2;
+ va_copy(ap2, ap);
+ async_safe_format_log_va_list(5 - prio, "linker", fmt, ap2);
+ va_end(ap2);
+
+ async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
+ write(STDERR_FILENO, "\n", 1);
}
void linker_log(int prio, const char* fmt, ...) {
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index 477b009..3aab185 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -33,11 +33,6 @@
// INFO, TRACE, and DEBUG calls in the source). This will only
// affect new processes being launched.
-// By default, traces are sent to logcat, with the "linker" tag. You can
-// change this to go to stdout instead by setting the definition of
-// LINKER_DEBUG_TO_LOG to 0.
-#define LINKER_DEBUG_TO_LOG 1
-
#define TRACE_DEBUG 1
#define DO_TRACE_LOOKUP 1
#define DO_TRACE_RELO 1
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 2b230a8..a625af7 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -245,6 +245,7 @@
va_start(ap, fmt);
async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
+ write(STDERR_FILENO, "\n", 1);
va_end(ap);
va_start(ap, fmt);
@@ -255,7 +256,7 @@
}
static void __linker_cannot_link(const char* argv0) {
- __linker_error("CANNOT LINK EXECUTABLE \"%s\": %s\n",
+ __linker_error("CANNOT LINK EXECUTABLE \"%s\": %s",
argv0,
linker_get_error_buffer());
}
@@ -267,26 +268,26 @@
ExecutableInfo result = {};
if (orig_path[0] != '/') {
- __linker_error("error: expected absolute path: \"%s\"\n", orig_path);
+ __linker_error("error: expected absolute path: \"%s\"", orig_path);
}
off64_t file_offset;
android::base::unique_fd fd(open_executable(orig_path, &file_offset, &result.path));
if (fd.get() == -1) {
- __linker_error("error: unable to open file \"%s\"\n", orig_path);
+ __linker_error("error: unable to open file \"%s\"", orig_path);
}
if (TEMP_FAILURE_RETRY(fstat(fd.get(), &result.file_stat)) == -1) {
- __linker_error("error: unable to stat \"%s\": %s\n", result.path.c_str(), strerror(errno));
+ __linker_error("error: unable to stat \"%s\": %m", result.path.c_str());
}
ElfReader elf_reader;
if (!elf_reader.Read(result.path.c_str(), fd.get(), file_offset, result.file_stat.st_size)) {
- __linker_error("error: %s\n", linker_get_error_buffer());
+ __linker_error("error: %s", linker_get_error_buffer());
}
address_space_params address_space;
if (!elf_reader.Load(&address_space)) {
- __linker_error("error: %s\n", linker_get_error_buffer());
+ __linker_error("error: %s", linker_get_error_buffer());
}
result.phdr = elf_reader.loaded_phdr();
@@ -333,11 +334,7 @@
if (getenv("LD_SHOW_AUXV") != nullptr) ld_show_auxv(args.auxv);
-#if defined(__LP64__)
- INFO("[ Android dynamic linker (64-bit) ]");
-#else
- INFO("[ Android dynamic linker (32-bit) ]");
-#endif
+ INFO("[ Android dynamic linker (" ABI_STRING ") ]");
// These should have been sanitized by __libc_init_AT_SECURE, but the test
// doesn't cost us anything.
@@ -401,8 +398,7 @@
if (note_gnu_property.IsBTICompatible() &&
(phdr_table_protect_segments(somain->phdr, somain->phnum, somain->load_bias,
somain->should_pad_segments(), ¬e_gnu_property) < 0)) {
- __linker_error("error: can't protect segments for \"%s\": %s", exe_info.path.c_str(),
- strerror(errno));
+ __linker_error("error: can't protect segments for \"%s\": %m", exe_info.path.c_str());
}
}
#endif
@@ -427,7 +423,7 @@
// and the NDK no longer supports earlier API levels.
if (elf_hdr->e_type != ET_DYN) {
__linker_error("error: %s: Android only supports position-independent "
- "executables (-fPIE)\n", exe_info.path.c_str());
+ "executables (-fPIE)", exe_info.path.c_str());
}
// Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
@@ -695,7 +691,7 @@
// fallback.
__libc_sysinfo = reinterpret_cast<void*>(__libc_int0x80);
#endif
- __linker_error("error: linker cannot load itself\n");
+ __linker_error("error: linker cannot load itself");
}
static ElfW(Addr) __attribute__((noinline))
diff --git a/linker/linker_relocate.cpp b/linker/linker_relocate.cpp
index 3e36114..5f993ba 100644
--- a/linker/linker_relocate.cpp
+++ b/linker/linker_relocate.cpp
@@ -627,7 +627,7 @@
android_relocs_[1] == 'P' &&
android_relocs_[2] == 'S' &&
android_relocs_[3] == '2') {
- DEBUG("[ android relocating %s ]", get_realpath());
+ DEBUG("[ relocating %s android rel/rela ]", get_realpath());
const uint8_t* packed_relocs = android_relocs_ + 4;
const size_t packed_relocs_size = android_relocs_size_ - 4;
diff --git a/tests/prebuilt-elf-files/arm64/libtest_empty.so b/tests/prebuilt-elf-files/arm64/libtest_empty.so
index d8775b6..76c569b 100755
--- a/tests/prebuilt-elf-files/arm64/libtest_empty.so
+++ b/tests/prebuilt-elf-files/arm64/libtest_empty.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_empty.so b/tests/prebuilt-elf-files/x86_64/libtest_empty.so
index c3f3638..ce519b2 100755
--- a/tests/prebuilt-elf-files/x86_64/libtest_empty.so
+++ b/tests/prebuilt-elf-files/x86_64/libtest_empty.so
Binary files differ