bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/26404] ld: INSERT [AFTER|BEFORE] variant for extension purposes


From: i at maskray dot me
Subject: [Bug ld/26404] ld: INSERT [AFTER|BEFORE] variant for extension purposes
Date: Fri, 05 Mar 2021 19:36:38 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=26404

--- Comment #8 from Fangrui Song <i at maskray dot me> ---
(In reply to Nick Clifton from comment #7)
> (In reply to Fangrui Song from comment #6)
> 
> > scriptfile defines multiple SECTIONS commands. Each SECTIONS defines exactly
> > one output section (for the first implementation we make the scope as narrow
> > as possible).
> > 
> >   SECTIONS {
> >     .foo : { KEEP(*(.foo)) }
> 
> If there already is a .foo section in the linker script, should any kind of
> message be issued ?  I assume not by default, but maybe if the --verbose
> option is active then it would be helpful to know that the override has
> happened.  Also, if --verbose is used, then presumably the overwritten
> version is the one that should be displayed.

Sounds good.

> > If the main script defines .foo, its .foo is overwritten;
> > if the main script does not define .foo, the new .foo is inserted as an
> > orphan (the regular orphan placement rule applies).
> 
> This might be a problem as section placement is often very important.
> We may need to implement your INSERT BEFORE/AFTER idea as well.

Adding an orphan section is probably more important than supporting overwriting
an existing output section description.
For regular applications, users want to control the properties of new metadata
sections: (1) add KEEP (2) set alignment (3) define start/stop symbols (4) SORT
(5) ...
They don't precise placement. The default orphan placement rule likely works
and they just want to leverage that.

INSERT BEFORE/AFTER can be awakward because the user has to specify an existing
output section, otherwise an error will be reported:

  % ld.bfd -T insert-not-exist.test a.o -o /dev/null
  ld.bfd: .not_exist not found for insert

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]