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

Message ID 20250110233706.1823649-3-hjl.tools@gmail.com
State New
Headers
Series Add lto and none-lto input 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-arm fail Test failed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 fail Test failed

Commit Message

H.J. Lu Jan. 10, 2025, 11:37 p.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 | 10 ++++++++++
 1 file changed, 10 insertions(+)
  

Comments

Hans-Peter Nilsson Jan. 11, 2025, 7:06 a.m. UTC | #1
Random review comment:

On Sat, 11 Jan 2025, H.J. Lu wrote:

> 	* ld.texi: Document mixing IR and non-IR relocatable files for
> 	"ld -r".

> +files.  Linker will extract it as input when creating executable or shared

"*The* linker will extract it"

brgds, H-P
  
Fangrui Song Jan. 11, 2025, 4:45 p.m. UTC | #2
On Fri, Jan 10, 2025 at 3:39 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
>         * 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 | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/ld/ld.texi b/ld/ld.texi
> index da714a20855..496dd5e5f83 100644
> --- a/ld/ld.texi
> +++ b/ld/ld.texi
> @@ -1126,6 +1126,16 @@ 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 input files contain both IR and non-IR relocatable
> +files, 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 input
> +files.  Linker will extract it as input when creating executable or shared
> +library.

I have some questions when reading the description:

* Is LTO performed on the IR files?
* Is it true that  the output sections are from the LTO compilation of
the IR files while there is a special .gnu_object_only section whose
content is a relocatable file that merges all non-IR relocatable
files?

> +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}
> --
> 2.47.1
>
  
H.J. Lu Jan. 11, 2025, 11:49 p.m. UTC | #3
On Sat, Jan 11, 2025 at 3:06 PM Hans-Peter Nilsson <hp@bitrange.com> wrote:
>
> Random review comment:
>
> On Sat, 11 Jan 2025, H.J. Lu wrote:
>
> >       * ld.texi: Document mixing IR and non-IR relocatable files for
> >       "ld -r".
>
> > +files.  Linker will extract it as input when creating executable or shared
>
> "*The* linker will extract it"

Fixed.

> brgds, H-P

Thanks.
  
H.J. Lu Jan. 11, 2025, 11:52 p.m. UTC | #4
On Sun, Jan 12, 2025 at 12:45 AM Fangrui Song <i@maskray.me> wrote:
>
> On Fri, Jan 10, 2025 at 3:39 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> >         * 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 | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/ld/ld.texi b/ld/ld.texi
> > index da714a20855..496dd5e5f83 100644
> > --- a/ld/ld.texi
> > +++ b/ld/ld.texi
> > @@ -1126,6 +1126,16 @@ 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 input files contain both IR and non-IR relocatable
> > +files, 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 input
> > +files.  Linker will extract it as input when creating executable or shared
> > +library.
>
> I have some questions when reading the description:

My wording isn't clear.  How about this

On ELF platforms, when the 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.
The linker will extract it as a separate input when creating the output.

> * Is LTO performed on the IR files?

LTO is optional.

> * Is it true that  the output sections are from the LTO compilation of
> the IR files while there is a special .gnu_object_only section whose
> content is a relocatable file that merges all non-IR relocatable
> files?

No.  See my new wording above.

>
> > +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}
> > --
> > 2.47.1
> >
  

Patch

diff --git a/ld/ld.texi b/ld/ld.texi
index da714a20855..496dd5e5f83 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -1126,6 +1126,16 @@  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 input files contain both IR and non-IR relocatable
+files, 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 input
+files.  Linker will extract it as input when creating executable or shared
+library.
+
+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}