* [PATCH] Fix ld/x86: reduce testsuite dependency on system object files
@ 2023-12-01 17:21 H.J. Lu
2023-12-04 7:27 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2023-12-01 17:21 UTC (permalink / raw)
To: binutils
commit eab996435fe65a421541f59557c5f1fd427573a3
Author: Jan Beulich <jbeulich@suse.com>
Date: Tue Nov 7 13:58:32 2023 +0100
ld/x86: reduce testsuite dependency on system object files
changed some C compiler tests to assembler/linker tests which introduced
2 problems:
1. It broke x32 binutils tests since --64 was passed to assembler, but
-m elf_x86_64 wasn't passed to linker.
2. -nostdlib was passed to C compiler driver to exclude standard run-time
files which should be avoided with -r option for linker tests.
Fix them by passing -m elf_x86_64 to linker and removing -nostdlib for
linker tests with -r.
PR ld/30722
* testsuite/ld-x86-64/x86-64.exp: Pass -m elf_x86_64 to linker
for tests with --64. Remove -nostdlib for tests with -r.
---
ld/testsuite/ld-x86-64/x86-64.exp | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 71ecc92f081..95a2986265b 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -2101,7 +2101,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 3" \
- "" \
+ "-m elf_x86_64" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-stk.s property-x86-1.s} \
@@ -2110,7 +2110,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 3 (.o)" \
- "-r -nostdlib" \
+ "-m elf_x86_64 -r" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-x86-1.s property-stk.s} \
@@ -2119,7 +2119,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 3 (.so)" \
- "-shared" \
+ "-m elf_x86_64 -shared" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-x86-1.s property-stk.s} \
@@ -2128,7 +2128,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 4" \
- "" \
+ "-m elf_x86_64" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-stk.s property-x86-1.s property-x86-2.s} \
@@ -2137,7 +2137,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 4 (.o)" \
- "-r -nostdlib" \
+ "-m elf_x86_64 -r" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-x86-2.s property-x86-1.s property-stk.s} \
@@ -2146,7 +2146,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 4 (.so)" \
- "-shared" \
+ "-m elf_x86_64 -shared" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-x86-2.s property-x86-1.s property-stk.s} \
@@ -2155,7 +2155,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 4 (-z stack-size=0)" \
- "-z stack-size=0" \
+ "-m elf_x86_64 -z stack-size=0" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-stk.s property-x86-1.s property-x86-2.s} \
@@ -2164,7 +2164,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 5" \
- "-z stack-size=0x900000" \
+ "-m elf_x86_64 -z stack-size=0x900000" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-stk.s property-x86-1.s property-x86-2.s} \
@@ -2173,7 +2173,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 5 (.o)" \
- "-r -nostdlib -z stack-size=0x900000" \
+ "-m elf_x86_64 -r -z stack-size=0x900000" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-x86-2.s property-x86-1.s property-stk.s} \
@@ -2182,7 +2182,7 @@ run_ld_link_tests [list \
] \
[list \
"Build property 5 (.so)" \
- "-shared -z stack-size=0x900000" \
+ "-m elf_x86_64 -shared -z stack-size=0x900000" \
"" \
"--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
{property-x86-2.s property-x86-1.s property-stk.s} \
--
2.41.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix ld/x86: reduce testsuite dependency on system object files
2023-12-01 17:21 [PATCH] Fix ld/x86: reduce testsuite dependency on system object files H.J. Lu
@ 2023-12-04 7:27 ` Jan Beulich
2023-12-06 17:25 ` H.J. Lu
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2023-12-04 7:27 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On 01.12.2023 18:21, H.J. Lu wrote:
> commit eab996435fe65a421541f59557c5f1fd427573a3
> Author: Jan Beulich <jbeulich@suse.com>
> Date: Tue Nov 7 13:58:32 2023 +0100
>
> ld/x86: reduce testsuite dependency on system object files
>
> changed some C compiler tests to assembler/linker tests which introduced
> 2 problems:
>
> 1. It broke x32 binutils tests since --64 was passed to assembler, but
> -m elf_x86_64 wasn't passed to linker.
What kind of configuration and/or testing would I have needed to do to see
those failures? Quite obviously I wouldn't have committed (nor even
submitted) this change with known failing tests.
> 2. -nostdlib was passed to C compiler driver to exclude standard run-time
> files which should be avoided with -r option for linker tests.
Already before my change -nostdlib was used together with -r.
> Fix them by passing -m elf_x86_64 to linker and removing -nostdlib for
> linker tests with -r.
>
> PR ld/30722
> * testsuite/ld-x86-64/x86-64.exp: Pass -m elf_x86_64 to linker
> for tests with --64. Remove -nostdlib for tests with -r.
> ---
> ld/testsuite/ld-x86-64/x86-64.exp | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
I assume you're going to get to addressing the wider underlying issue in
the testsuite?
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix ld/x86: reduce testsuite dependency on system object files
2023-12-04 7:27 ` Jan Beulich
@ 2023-12-06 17:25 ` H.J. Lu
2023-12-06 18:12 ` Fangrui Song
2023-12-07 7:17 ` Jan Beulich
0 siblings, 2 replies; 5+ messages in thread
From: H.J. Lu @ 2023-12-06 17:25 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Sun, Dec 3, 2023 at 11:27 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 01.12.2023 18:21, H.J. Lu wrote:
> > commit eab996435fe65a421541f59557c5f1fd427573a3
> > Author: Jan Beulich <jbeulich@suse.com>
> > Date: Tue Nov 7 13:58:32 2023 +0100
> >
> > ld/x86: reduce testsuite dependency on system object files
> >
> > changed some C compiler tests to assembler/linker tests which introduced
> > 2 problems:
> >
> > 1. It broke x32 binutils tests since --64 was passed to assembler, but
> > -m elf_x86_64 wasn't passed to linker.
>
> What kind of configuration and/or testing would I have needed to do to see
> those failures? Quite obviously I wouldn't have committed (nor even
> submitted) this change with known failing tests.
You need an x32 toolchain, like
[hjl@gnu-cfl-3 binutils-x32]$ file /usr/localx32/bin/ld
/usr/localx32/bin/ld: ELF 32-bit LSB executable, x86-64, version 1
(SYSV), dynamically linked, interpreter /libx32/ld-linux-x32.so.2,
BuildID[sha1]=5f1a971f969147c466cac7f7a2d0ad89899e06b9, for GNU/Linux
3.4.0, stripped
[hjl@gnu-cfl-3 binutils-x32]$ file /usr/gcc-11.2.1-mx32/bin/gcc
/usr/gcc-11.2.1-mx32/bin/gcc: ELF 32-bit LSB executable, x86-64,
version 1 (SYSV), dynamically linked, interpreter
/libx32/ld-linux-x32.so.2,
BuildID[sha1]=c0ee7a727c32f7933dbfb433d59ffdf99295030c, for GNU/Linux
3.4.0, stripped
[hjl@gnu-cfl-3 binutils-x32]$
> > 2. -nostdlib was passed to C compiler driver to exclude standard run-time
> > files which should be avoided with -r option for linker tests.
>
> Already before my change -nostdlib was used together with -r.
-nostdlib is a GCC driver option. It is used like
# gcc -r -nostdlib ....
But it is wrong to do
$ ld -r -nostdlib
> > Fix them by passing -m elf_x86_64 to linker and removing -nostdlib for
> > linker tests with -r.
> >
> > PR ld/30722
> > * testsuite/ld-x86-64/x86-64.exp: Pass -m elf_x86_64 to linker
> > for tests with --64. Remove -nostdlib for tests with -r.
> > ---
> > ld/testsuite/ld-x86-64/x86-64.exp | 20 ++++++++++----------
> > 1 file changed, 10 insertions(+), 10 deletions(-)
>
> I assume you're going to get to addressing the wider underlying issue in
> the testsuite?
>
> Jan
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix ld/x86: reduce testsuite dependency on system object files
2023-12-06 17:25 ` H.J. Lu
@ 2023-12-06 18:12 ` Fangrui Song
2023-12-07 7:17 ` Jan Beulich
1 sibling, 0 replies; 5+ messages in thread
From: Fangrui Song @ 2023-12-06 18:12 UTC (permalink / raw)
To: H.J. Lu; +Cc: Jan Beulich, binutils
On Wed, Dec 6, 2023 at 9:25 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, Dec 3, 2023 at 11:27 PM Jan Beulich <jbeulich@suse.com> wrote:
> >
> > On 01.12.2023 18:21, H.J. Lu wrote:
> > > commit eab996435fe65a421541f59557c5f1fd427573a3
> > > Author: Jan Beulich <jbeulich@suse.com>
> > > Date: Tue Nov 7 13:58:32 2023 +0100
> > >
> > > ld/x86: reduce testsuite dependency on system object files
> > >
> > > changed some C compiler tests to assembler/linker tests which introduced
> > > 2 problems:
> > >
> > > 1. It broke x32 binutils tests since --64 was passed to assembler, but
> > > -m elf_x86_64 wasn't passed to linker.
> >
> > What kind of configuration and/or testing would I have needed to do to see
> > those failures? Quite obviously I wouldn't have committed (nor even
> > submitted) this change with known failing tests.
>
> You need an x32 toolchain, like
>
> [hjl@gnu-cfl-3 binutils-x32]$ file /usr/localx32/bin/ld
> /usr/localx32/bin/ld: ELF 32-bit LSB executable, x86-64, version 1
> (SYSV), dynamically linked, interpreter /libx32/ld-linux-x32.so.2,
> BuildID[sha1]=5f1a971f969147c466cac7f7a2d0ad89899e06b9, for GNU/Linux
> 3.4.0, stripped
> [hjl@gnu-cfl-3 binutils-x32]$ file /usr/gcc-11.2.1-mx32/bin/gcc
> /usr/gcc-11.2.1-mx32/bin/gcc: ELF 32-bit LSB executable, x86-64,
> version 1 (SYSV), dynamically linked, interpreter
> /libx32/ld-linux-x32.so.2,
> BuildID[sha1]=c0ee7a727c32f7933dbfb433d59ffdf99295030c, for GNU/Linux
> 3.4.0, stripped
> [hjl@gnu-cfl-3 binutils-x32]$
>
> > > 2. -nostdlib was passed to C compiler driver to exclude standard run-time
> > > files which should be avoided with -r option for linker tests.
> >
> > Already before my change -nostdlib was used together with -r.
>
> -nostdlib is a GCC driver option. It is used like
>
> # gcc -r -nostdlib ....
>
> But it is wrong to do
>
> $ ld -r -nostdlib
ld -nostdlib has a confusing name and is entirely unrelated to GCC
driver -nostdlib.
(gcc -nostdlib doesn't pass -nostdlib to ld.)
-nostdlib disables SEARCH_DIR in a linker script.
% cat a.script
SEARCH_DIR("a.dir")
% ld.bfd a.o a.script -lls
ld.bfd: warning: type and size of dynamic symbol `_bar' are not defined
% ld.bfd a.o a.script -lls -nostdlib
ld.bfd: cannot find -lls: file format not recognized
> > > Fix them by passing -m elf_x86_64 to linker and removing -nostdlib for
> > > linker tests with -r.
> > >
> > > PR ld/30722
> > > * testsuite/ld-x86-64/x86-64.exp: Pass -m elf_x86_64 to linker
> > > for tests with --64. Remove -nostdlib for tests with -r.
> > > ---
> > > ld/testsuite/ld-x86-64/x86-64.exp | 20 ++++++++++----------
> > > 1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > I assume you're going to get to addressing the wider underlying issue in
> > the testsuite?
> >
> > Jan
>
>
>
> --
> H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix ld/x86: reduce testsuite dependency on system object files
2023-12-06 17:25 ` H.J. Lu
2023-12-06 18:12 ` Fangrui Song
@ 2023-12-07 7:17 ` Jan Beulich
1 sibling, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2023-12-07 7:17 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On 06.12.2023 18:25, H.J. Lu wrote:
> On Sun, Dec 3, 2023 at 11:27 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 01.12.2023 18:21, H.J. Lu wrote:
>>> commit eab996435fe65a421541f59557c5f1fd427573a3
>>> Author: Jan Beulich <jbeulich@suse.com>
>>> Date: Tue Nov 7 13:58:32 2023 +0100
>>>
>>> ld/x86: reduce testsuite dependency on system object files
>>>
>>> changed some C compiler tests to assembler/linker tests which introduced
>>> 2 problems:
>>>
>>> 1. It broke x32 binutils tests since --64 was passed to assembler, but
>>> -m elf_x86_64 wasn't passed to linker.
>>
>> What kind of configuration and/or testing would I have needed to do to see
>> those failures? Quite obviously I wouldn't have committed (nor even
>> submitted) this change with known failing tests.
>
> You need an x32 toolchain, like
>
> [hjl@gnu-cfl-3 binutils-x32]$ file /usr/localx32/bin/ld
> /usr/localx32/bin/ld: ELF 32-bit LSB executable, x86-64, version 1
> (SYSV), dynamically linked, interpreter /libx32/ld-linux-x32.so.2,
> BuildID[sha1]=5f1a971f969147c466cac7f7a2d0ad89899e06b9, for GNU/Linux
> 3.4.0, stripped
> [hjl@gnu-cfl-3 binutils-x32]$ file /usr/gcc-11.2.1-mx32/bin/gcc
> /usr/gcc-11.2.1-mx32/bin/gcc: ELF 32-bit LSB executable, x86-64,
> version 1 (SYSV), dynamically linked, interpreter
> /libx32/ld-linux-x32.so.2,
> BuildID[sha1]=c0ee7a727c32f7933dbfb433d59ffdf99295030c, for GNU/Linux
> 3.4.0, stripped
> [hjl@gnu-cfl-3 binutils-x32]$
>
>>> 2. -nostdlib was passed to C compiler driver to exclude standard run-time
>>> files which should be avoided with -r option for linker tests.
>>
>> Already before my change -nostdlib was used together with -r.
>
> -nostdlib is a GCC driver option. It is used like
>
> # gcc -r -nostdlib ....
And what use has the option with -r?
> But it is wrong to do
>
> $ ld -r -nostdlib
Well, as per Fangrui, not so much wrong than (again) meaningless.
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-07 7:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01 17:21 [PATCH] Fix ld/x86: reduce testsuite dependency on system object files H.J. Lu
2023-12-04 7:27 ` Jan Beulich
2023-12-06 17:25 ` H.J. Lu
2023-12-06 18:12 ` Fangrui Song
2023-12-07 7:17 ` Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).