[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220322140253.GJ10306@1wt.eu>
Date: Tue, 22 Mar 2022 15:02:53 +0100
From: Willy Tarreau <w@....eu>
To: Ammar Faizi <ammarfaizi2@...weeb.org>
Cc: David Laight <David.Laight@...lab.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>,
Nugraha <richiisei@...il.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
"x86@...nel.org" <x86@...nel.org>,
"llvm@...ts.linux.dev" <llvm@...ts.linux.dev>
Subject: Re: [RFC PATCH v2 3/8] tools/nolibc: i386: Implement syscall with 6
arguments
On Tue, Mar 22, 2022 at 08:56:44PM +0700, Ammar Faizi wrote:
> On 3/22/22 8:54 PM, Ammar Faizi wrote:
> >
> > Willy, something goes wrong here...
> >
> > ammarfaizi2@...egral2:~/work/linux.work/tools/include/nolibc$ taskset -c 0 gcc -ffreestanding -nostdlib -nostartfiles test.c -o test -lgcc
> > /usr/bin/ld: /tmp/ccHiYiks.o: warning: relocation against `environ' in read-only section `.text'
> > /usr/bin/ld: /tmp/ccHiYiks.o: in function `getenv':
> > test.c:(.text+0x1f76): undefined reference to `environ'
> > /usr/bin/ld: test.c:(.text+0x1fc3): undefined reference to `environ'
> > /usr/bin/ld: test.c:(.text+0x1ffc): undefined reference to `environ'
> > /usr/bin/ld: test.c:(.text+0x2021): undefined reference to `environ'
> > /usr/bin/ld: test.c:(.text+0x2049): undefined reference to `environ'
> > /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
> > collect2: error: ld returned 1 exit status
> > ammarfaizi2@...egral2:~/work/linux.work/tools/include/nolibc$
> >
> >
> > I suspect it's caused by commit:
> >
> > commit c970abe796019b3d576fd154a54b94efb35c02b1
> > Author: Willy Tarreau <w@....eu>
> > Date: Mon Mar 21 18:33:08 2022 +0100
> >
> > tools/nolibc/stdlib: add a simple getenv() implementation
> > This implementation relies on an extern definition of the environ
> > variable, that the caller must declare and initialize from envp.
> > Signed-off-by: Willy Tarreau <w@....eu>
> > Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
> >
> > I will take a look deeper on this...
>
> This bug only exists when compiling without optimization.
Indeed, reproduced. I can bypass it by adding __attribute__((weak)) on
the environ declaration in getenv(). Will send a patch later.
Thanks,
Willy
Powered by blists - more mailing lists