public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: James Y Knight via Gnu-gabi <gnu-gabi@sourceware.org>
Subject: Re: [RFC] Proposal for new ELF extension - "Symbol meta-information"
Date: Wed, 2 Sep 2020 11:26:23 +0100	[thread overview]
Message-ID: <20200902102623.w7gj7zxhkitonzfi@jozef-acer-manjaro> (raw)
In-Reply-To: <873641u0hn.fsf@oldenburg2.str.redhat.com>

On Tue, Sep 01, 2020 at 02:48:04PM +0200, Florian Weimer wrote:
> * Jozef Lawrynowicz:
> 
> > I can imagine how the behavior could be implemented without any special
> > handling from the linker, if the compiler instead maps the printf calls to the
> > minimum required printf implementation, and the library has something
> > like this:
> 
> Yes, exactly my thought.  It's definitely less action at a distance.
> 
> > Do you have any opinions on the inclusion of the symbol meta-information
> > mechanism itself within the GNU gABI?
> 
> In the past, we just added a parallel table to the symbol table when we
> needed to extend it.  I think SHT_GNU_versym is the most widely used
> example.  This has the advantage that it is so much simpler.

It seems that the benefits of having a parallel symbol table outweigh
any concerns about wasted space and the large amount of symbol metainfo
entries which would not have any content.
Since entry size is fixed, if you stored the header information in the
initial NULL entry then there is the additional benefit that you could
theoretically keep .symtab_meta in sync with .symtab by
adding/removing symbols at a given index as required.

> 
> The main risk is processing objects with tools that don't know about the
> symbol table relationship of this parallel tables.  To deal with that,
> having a special section that lists the section types that absolutely
> need to be understood by tools in order to process the object in various
> ways (a distinction between reading, linking, and outputting might make
> sense) could really be helpful.  You would get a precise error, rather
> than a corrupt output file.
> 
> I'm not sure if it is possible to have meaningful symbol metadata that
> can be processed by old tools in some meaningful way, tools that have no
> prior knowledge of it.  It's very hard to design these things,
> especially when we have only three established use cases.

Some standardization of parallel symbol tables would certainly be
forward thinking and enable future extensions which use parallel symbol
tables to be kept in sync with .symtab, even if those older tools don't
understand the extension itself.

If we also consider SMT_NOINIT removed as a generic metainfo type, based
on the feedback received from the ELF gABI discussions, then that leaves
the SMT_RETAIN and SMT_LOCATION metainfo types.

These types in particular generally operate on the section level,
at least, the behavior the linker will eventually
apply will be to the containing section, not the symbol itself.

So they could be implemented using new section flags (sh_flags).
There is plenty of space for additional sh_flags (unlike symbol
flags).

- SMT_RETAIN
  The linker will only garbage collect sections, not individual
  symbols.
  A new section flag indicates that the section should be retained
  by the linker, even if it would be garbage collected. 
  Whatever section contains the symbol that the "retain"
  attribute is applied to will have the "retain" sh_flags bit set.

- SMT_LOCATION
  The linker can only place sections at a specific address,
  not individual symbols.
  A new section flag indicates that the section should be placed at a
  specific VMA in the executable file by the linker.
  The address could be set in the sh_addr field, or encoded in the
  section name.

Since the overall aim is to support the "retain" and "location" C/C++
attributes, perhaps this is the most appropriate way forward...

Thanks,
Jozef

  reply	other threads:[~2020-09-02 10:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 11:58 Jozef Lawrynowicz
2020-08-31 12:23 ` Florian Weimer
2020-08-31 13:14   ` Jozef Lawrynowicz
2020-08-31 13:45   ` James Y Knight
2020-09-01 11:20     ` Florian Weimer
2020-09-01 12:19       ` Jozef Lawrynowicz
2020-09-01 12:48         ` Florian Weimer
2020-09-02 10:26           ` Jozef Lawrynowicz [this message]
2020-09-03 16:49             ` Jozef Lawrynowicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200902102623.w7gj7zxhkitonzfi@jozef-acer-manjaro \
    --to=jozef.l@mittosystems.com \
    --cc=fweimer@redhat.com \
    --cc=gnu-gabi@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).