ld: compressed sections that depend on the symtab and strtab contents (linker people, am I crazy?)

Nick Alcock nick.alcock@oracle.com
Thu Aug 8 09:35:00 GMT 2019

On 7 Aug 2019, Nick Clifton stated:

>   It sounds to me like you might be better off not trying to optimize
>   the CTF string table at all.  Just output it with duplicated strings
>   and keep things simple.  You could then add a feature to objcopy which
>   would go through a fully linked binary and remove duplicates.  There
>   is already precedence for this kind of thing with its note merging
>   capabilities.

Unfortunately that would mean slowing down every single link that wants
to use libctf, writing twice as much stuff out to disk (and for big
binaries that's *bad*), and requiring the use of an additional tool in
an unobvious way just to get libctf to work in accordance with something
that's actually been in its spec since the mid-2000s.

(Also, we do need to shuffle the function and data object sections into
symtab order as well, though libctf hasn't learned to do that yet. That
will *also* change the size of the CTF section after compression.)

If we're doing that, why bother compressing the CTF sections in ld? Why
bother merging the CTF sections at all? I mean we're already running a
post-facto tool! Now personally I'd call that tool a "linker"... but if
GNU ld really isn't up to this, I suppose we could wrap something around
it and put it in the compiler specfile. This breaks every single person
who runs ld by hand, of course, requires even more coordinated changes
to GCC, and leaves us with a libctf in binutils that is mostly used by
things *outside* binutils, which feels very strange.

But I don't think this is necessary! I know I've been silent for ages,
but this is *not* because I've been wrestling with ld: I fixed the
breaks-the-assembler problem the day after I reported it. I'm using it
for real before I try to post again (work deadline), with very large
links and custom third-party users of libctf's linking machinery to make
sure I've got the API right, and am pruning a lot of bugs out of the
libctf portion and lifting a lot of long-standing restrictions. That's
taking time... and I'm going on holiday in two days so the next posting
(of the whole series, a rather long one by now) will probably be around
Tuesday 27th. (I'd rather do that than post something and then go away
so I can't reply to any reviews.)

(If this was an attempt to make my life easier to find a way to not have
to deal with ld, thank you! It has been a memorable experience, shall we
say. :) but the denial despair and anger are over and it actually works
now, and doesn't seem to break anything.)

More information about the Binutils mailing list