RFC: ELF: Deduplicate strings without a null terminator

Michael Matz matz@suse.de
Thu Apr 17 14:19:50 GMT 2025


Hello,

On Thu, 17 Apr 2025, Trevor Gross wrote:

> > On Thu, Apr 17, 2025 at 12:56:27AM -0400, Trevor Gross wrote:
> > > Is there any appetite for providing linkers a way to merge binary
> > > sequences that are not null-terminated?
> >
> > Already supported in the GNU linker.
> 
> Could you point me to more information about what the rules for this
> are?

It's simply SHF_MERGE sections without SHF_STRINGS.  Those contain 
fixed-size entities, and the section header says what that size is.  So, 
put all your size-prefixed strings/blobs into SHF_MERGE sections (one such 
section per size), and they will be merged by GNU ld.


Ciao,
Michael.


More information about the Binutils mailing list