lkml.org 
[lkml]   [2022]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 3/9] tools/nolibc: Remove .global _start from the entry point code
Date
Building with clang yields the following error:
```
<inline asm>:3:1: error: _start changed binding to STB_GLOBAL
.global _start
^
1 error generated.
```
Make sure only specify one between `.global _start` and `.weak _start`.
Remove `.global _start`.

Cc: llvm@lists.linux.dev
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
===

@@ Changelog:

Link v1: https://lore.gnuweeb.org/gwml/20220324073039.140946-3-ammarfaizi2@gnuweeb.org
v1 -> v2:
- Switch the order with the patch that replaces `asm` with `__asm__`.

Link RFC v2: https://lore.kernel.org/llvm/20220322102115.186179-3-ammarfaizi2@gnuweeb.org
RFC v2 -> v1:
- Append Reviewed-by tag from Nick.
- s/Removing/remove/

Link RFC v1: https://lore.kernel.org/llvm/20220320093750.159991-3-ammarfaizi2@gnuweeb.org
RFC v1 -> RFC v2:
- Remove all `.global _start` for all build (GCC and Clang) instead of
removing all `.weak _start` for clang build (Comment from Willy).
---
tools/include/nolibc/arch-aarch64.h | 1 -
tools/include/nolibc/arch-arm.h | 1 -
tools/include/nolibc/arch-i386.h | 1 -
tools/include/nolibc/arch-mips.h | 1 -
tools/include/nolibc/arch-riscv.h | 1 -
tools/include/nolibc/arch-x86_64.h | 1 -
6 files changed, 6 deletions(-)

diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h
index b68443f63980..f68baf8f395f 100644
--- a/tools/include/nolibc/arch-aarch64.h
+++ b/tools/include/nolibc/arch-aarch64.h
@@ -184,7 +184,6 @@ struct sys_stat_struct {
/* startup code */
__asm__ (".section .text\n"
".weak _start\n"
- ".global _start\n"
"_start:\n"
"ldr x0, [sp]\n" // argc (x0) was in the stack
"add x1, sp, 8\n" // argv (x1) = sp
diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h
index 55fd9439b2e2..f31be8e967d6 100644
--- a/tools/include/nolibc/arch-arm.h
+++ b/tools/include/nolibc/arch-arm.h
@@ -177,7 +177,6 @@ struct sys_stat_struct {
/* startup code */
__asm__ (".section .text\n"
".weak _start\n"
- ".global _start\n"
"_start:\n"
#if defined(__THUMBEB__) || defined(__THUMBEL__)
/* We enter here in 32-bit mode but if some previous functions were in
diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h
index 136d5739e456..10aada40680d 100644
--- a/tools/include/nolibc/arch-i386.h
+++ b/tools/include/nolibc/arch-i386.h
@@ -176,7 +176,6 @@ struct sys_stat_struct {
*/
__asm__ (".section .text\n"
".weak _start\n"
- ".global _start\n"
"_start:\n"
"pop %eax\n" // argc (first arg, %eax)
"mov %esp, %ebx\n" // argv[] (second arg, %ebx)
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index cd587e539d7d..5fc5b8029bff 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -192,7 +192,6 @@ struct sys_stat_struct {
__asm__ (".section .text\n"
".weak __start\n"
".set nomips16\n"
- ".global __start\n"
".set noreorder\n"
".option pic0\n"
".ent __start\n"
diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h
index 8ec4c05fa69b..95e2b7924925 100644
--- a/tools/include/nolibc/arch-riscv.h
+++ b/tools/include/nolibc/arch-riscv.h
@@ -185,7 +185,6 @@ struct sys_stat_struct {
/* startup code */
__asm__ (".section .text\n"
".weak _start\n"
- ".global _start\n"
"_start:\n"
".option push\n"
".option norelax\n"
diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h
index 490530429ac9..0e1e9eb8545d 100644
--- a/tools/include/nolibc/arch-x86_64.h
+++ b/tools/include/nolibc/arch-x86_64.h
@@ -199,7 +199,6 @@ struct sys_stat_struct {
*/
__asm__ (".section .text\n"
".weak _start\n"
- ".global _start\n"
"_start:\n"
"pop %rdi\n" // argc (first arg, %rdi)
"mov %rsp, %rsi\n" // argv[] (second arg, %rsi)
--
Ammar Faizi
\
 
 \ /
  Last update: 2022-03-29 12:19    [W:0.123 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site