[v3,2/4] ld: Document mixing IR and non-IR objects for -r

Message ID 20250112070752.2883068-3-hjl.tools@gmail.com
State New
Headers
Series Add lto and none-lto output support for ld -r |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 fail Test failed
linaro-tcwg-bot/tcwg_binutils_check--master-arm fail Test failed

Commit Message

H.J. Lu Jan. 12, 2025, 7:07 a.m. UTC
  * ld.texi: Document mixing IR and non-IR relocatable files for
	"ld -r".

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 ld/ld.texi | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Andreas Schwab Jan. 12, 2025, 8:16 a.m. UTC | #1
On Jan 12 2025, H.J. Lu wrote:

> +On ELF platforms, when the relocatable output contains both IR and
> +non-IR contents, a .gnu_object_only section will be created to contain

Whatis IR?
  
H.J. Lu Jan. 12, 2025, 8:42 a.m. UTC | #2
On Sun, Jan 12, 2025 at 4:16 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Jan 12 2025, H.J. Lu wrote:
>
> > +On ELF platforms, when the relocatable output contains both IR and
> > +non-IR contents, a .gnu_object_only section will be created to contain
>
> Whatis IR?
>

How about this?

On ELF platforms, when the relocatable output contains both contents
which require link-time optimization (LTO) and contents which don't
require LTO, a .gnu_object_only section will be created to contain a
relocatable object file, as if @samp{-r} is applied to all relocatable
inputs which don't require LTO.  When processing a relocatable input
with a .gnu_object_only section, the linker will extract the
.gnu_object_only section as a separate input.
  
Sam James Jan. 12, 2025, 9:03 a.m. UTC | #3
"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Sun, Jan 12, 2025 at 4:16 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>
>> On Jan 12 2025, H.J. Lu wrote:
>>
>> > +On ELF platforms, when the relocatable output contains both IR and
>> > +non-IR contents, a .gnu_object_only section will be created to contain
>>
>> Whatis IR?
>>
>
> How about this?
>
> On ELF platforms, when the relocatable output contains both contents
> which require link-time optimization (LTO) and contents which don't
> require LTO, a .gnu_object_only section will be created to contain a
> relocatable object file, as if @samp{-r} is applied to all relocatable
> inputs which don't require LTO.  When processing a relocatable input
> with a .gnu_object_only section, the linker will extract the
> .gnu_object_only section as a separate input.

That reads well to me. Maybe we should include a reference to
-ffat-lto-objects.
  
H.J. Lu Jan. 12, 2025, 9:06 a.m. UTC | #4
On Sun, Jan 12, 2025 at 5:03 PM Sam James <sam@gentoo.org> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > On Sun, Jan 12, 2025 at 4:16 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
> >>
> >> On Jan 12 2025, H.J. Lu wrote:
> >>
> >> > +On ELF platforms, when the relocatable output contains both IR and
> >> > +non-IR contents, a .gnu_object_only section will be created to contain
> >>
> >> Whatis IR?
> >>
> >
> > How about this?
> >
> > On ELF platforms, when the relocatable output contains both contents
> > which require link-time optimization (LTO) and contents which don't
> > require LTO, a .gnu_object_only section will be created to contain a
> > relocatable object file, as if @samp{-r} is applied to all relocatable
> > inputs which don't require LTO.  When processing a relocatable input
> > with a .gnu_object_only section, the linker will extract the
> > .gnu_object_only section as a separate input.
>
> That reads well to me. Maybe we should include a reference to
> -ffat-lto-objects.

I am trying to avoid compiler options in the linker manual.
  
Sam James Jan. 12, 2025, 9:16 a.m. UTC | #5
"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Sun, Jan 12, 2025 at 5:03 PM Sam James <sam@gentoo.org> wrote:
>>
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>> > On Sun, Jan 12, 2025 at 4:16 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>> >>
>> >> On Jan 12 2025, H.J. Lu wrote:
>> >>
>> >> > +On ELF platforms, when the relocatable output contains both IR and
>> >> > +non-IR contents, a .gnu_object_only section will be created to contain
>> >>
>> >> Whatis IR?
>> >>
>> >
>> > How about this?
>> >
>> > On ELF platforms, when the relocatable output contains both contents
>> > which require link-time optimization (LTO) and contents which don't
>> > require LTO, a .gnu_object_only section will be created to contain a
>> > relocatable object file, as if @samp{-r} is applied to all relocatable
>> > inputs which don't require LTO.  When processing a relocatable input
>> > with a .gnu_object_only section, the linker will extract the
>> > .gnu_object_only section as a separate input.
>>
>> That reads well to me. Maybe we should include a reference to
>> -ffat-lto-objects.
>
> I am trying to avoid compiler options in the linker manual.

OK, fair enough. Can we compromise on including it in the commit
message, to help grepping/searching?
  
H.J. Lu Jan. 12, 2025, 9:40 a.m. UTC | #6
On Sun, Jan 12, 2025, 5:16 PM Sam James <sam@gentoo.org> wrote:

> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > On Sun, Jan 12, 2025 at 5:03 PM Sam James <sam@gentoo.org> wrote:
> >>
> >> "H.J. Lu" <hjl.tools@gmail.com> writes:
> >>
> >> > On Sun, Jan 12, 2025 at 4:16 PM Andreas Schwab <schwab@linux-m68k.org>
> wrote:
> >> >>
> >> >> On Jan 12 2025, H.J. Lu wrote:
> >> >>
> >> >> > +On ELF platforms, when the relocatable output contains both IR and
> >> >> > +non-IR contents, a .gnu_object_only section will be created to
> contain
> >> >>
> >> >> Whatis IR?
> >> >>
> >> >
> >> > How about this?
> >> >
> >> > On ELF platforms, when the relocatable output contains both contents
> >> > which require link-time optimization (LTO) and contents which don't
> >> > require LTO, a .gnu_object_only section will be created to contain a
> >> > relocatable object file, as if @samp{-r} is applied to all relocatable
> >> > inputs which don't require LTO.  When processing a relocatable input
> >> > with a .gnu_object_only section, the linker will extract the
> >> > .gnu_object_only section as a separate input.
> >>
> >> That reads well to me. Maybe we should include a reference to
> >> -ffat-lto-objects.
> >
> > I am trying to avoid compiler options in the linker manual.
>
> OK, fair enough. Can we compromise on including it in the commit
> message, to help grepping/searching?


Will do.

Thanks.


>
>
  
H.J. Lu Jan. 12, 2025, 10:09 a.m. UTC | #7
On Sun, Jan 12, 2025 at 5:40 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, Jan 12, 2025, 5:16 PM Sam James <sam@gentoo.org> wrote:
>>
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>> > On Sun, Jan 12, 2025 at 5:03 PM Sam James <sam@gentoo.org> wrote:
>> >>
>> >> "H.J. Lu" <hjl.tools@gmail.com> writes:
>> >>
>> >> > On Sun, Jan 12, 2025 at 4:16 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>> >> >>
>> >> >> On Jan 12 2025, H.J. Lu wrote:
>> >> >>
>> >> >> > +On ELF platforms, when the relocatable output contains both IR and
>> >> >> > +non-IR contents, a .gnu_object_only section will be created to contain
>> >> >>
>> >> >> Whatis IR?
>> >> >>
>> >> >
>> >> > How about this?
>> >> >
>> >> > On ELF platforms, when the relocatable output contains both contents
>> >> > which require link-time optimization (LTO) and contents which don't
>> >> > require LTO, a .gnu_object_only section will be created to contain a
>> >> > relocatable object file, as if @samp{-r} is applied to all relocatable
>> >> > inputs which don't require LTO.  When processing a relocatable input
>> >> > with a .gnu_object_only section, the linker will extract the
>> >> > .gnu_object_only section as a separate input.
>> >>
>> >> That reads well to me. Maybe we should include a reference to
>> >> -ffat-lto-objects.
>> >
>> > I am trying to avoid compiler options in the linker manual.
>>
>> OK, fair enough. Can we compromise on including it in the commit
>> message, to help grepping/searching?
>
>
> Will do.

 -ffat-lto-objects is unrelated to this since linkers can ignore either
LTO contents or no-LTO contents without causing any linker error
since they provide the same set of symbol definitions.

> Thanks.
>
>>
>>
  

Patch

diff --git a/ld/ld.texi b/ld/ld.texi
index da714a20855..f8a3f9df13a 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1126,6 +1126,17 @@  relocations.  Different output formats can have further restrictions; for
 example some @code{a.out}-based formats do not support partial linking
 with input files in other formats at all.
 
+On ELF platforms, when the relocatable output contains both IR and
+non-IR contents, a .gnu_object_only section will be created to contain
+a relocatable object file, as if @samp{-r} is applied to all non-IR
+relocatable inputs.  When processing a relocatable input with a
+.gnu_object_only section, the linker will extract the .gnu_object_only
+section as a separate input.
+
+Note that since @samp{-r} groups some sections from different input files
+together, there may be negative impacts on code size and locality in
+final executable or shared library.
+
 This option does the same thing as @samp{-i}.
 
 @kindex -R @var{file}