public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Suprateeka R Hegde <hegdesmailbox@gmail.com>
Cc: "Carlos O'Donell" <carlos@redhat.com>, gnu-gabi@sourceware.org
Subject: Re: RFC: ABI support for special memory area
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <CAMe9rOoQUFJBmcBp-3vdi-MTWq_K+3z+9sfD3os7r_OTaRnVkQ@mail.gmail.com> (raw)
In-Reply-To: <35fce20b-20e0-3d0e-1957-f3df124a05ac@gmail.com>

On Fri, Mar 31, 2017 at 6:44 AM, Suprateeka R Hegde
<hegdesmailbox@gmail.com> wrote:
> On 30-Mar-2017 10:10 PM, H.J. Lu wrote:
>>> However, I am just thinking that your earlier approach --
>>> __gnu_mbind_setup -- is better when shared libraries with GNU_MBIND
>>> segments are dlopen'ed. They dont have to iterate all over again to
>>> reach their PHDR. Or what is the recommendation for such dlopen'ed
>>> libraries?
>>
>> It is true that dl_iterate_phdr is called by every shared object, dlopened or
>> not, to locate its own PHDR.
>
> Lets put a one liner on best practices or guideline kind of. You have
> already made it clear in the example code. I am just thinking of putting
> them in words too.
>
> Lets say something like, each load module is expected to process only
> its special memory segments. To mean that shlibs/exe need not do any
> book-keeping to avoid multiple executions of the special memory setup
> for the same load module.
>
>>> And this dl_iterate_phdr(3) not being part of any standards, may change
>>> in a totally incompatible way in the future.
>>>
>>
>> dl_iterate_phdr isn't in any standard.  But it is in glibc.  Given that my
>> proposal is a GNU extension, it isn't a major issue.  Working with
>> existing glibc is a big plus.
>
> Awesome. Looks great. Thanks a lot for the new approach.
>
> --
> Supra

Here is the updated proposal.

Thanks.


-- 
H.J.
--
ABI support for special memory area

To section attributes, add

#define SHF_GNU_MBIND     0x00100000

for sections used to place data or text into a special memory area.
The section names should start with ".mbind" so that they won't be
grouped together with normal sections by link editor.  The sh_info
field indicates the special memory type.  SHF_GNU_MBIND is only
applicable to SHF_ALLOC sections.

The following memory types in the sh_info field are defined:

/* The highest bandwidth memory.   */
#define GNU_MBIND_HBW       0

To the "Program Header" section, add an inclusive range of segment types
for GNU_MBIND segments:

#define PT_GNU_MBIND_NUM    4096
#define PT_GNU_MBIND_LO     (PT_LOOS + 0x474e555)
#define PT_GNU_MBIND_HI     (PT_GNU_MBIND_LO + PT_GNU_MBIND_NUM - 1)

The array element specifies the location and size of a special memory area.
Each GNU_MBIND segment contains one GNU_MBIND section and the segment
type is PT_GNU_MBIND_LO plus the sh_info value.  If the sh_info value is
greater than PT_GNU_MBIND_NUM, no GNU_MBIND segment will be created.  Each
GNU_MBIND segment must be aligned at page boundary.  The interpretation of
the special memory area information is implementation-dependent.
Implementations may ignore GNU_MBIND segment.

Run-time support

Each load module is expected to process only its special memory segments.
There is no need for executable and shared objects to do any book-keeping
to avoid multiple executions of the special memory setup for the same
load module.

dl_iterate_phdr in the the GNU C library:

int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
                                      size_t size, void *data),
                     void *data);

is called via the .init_array section to process GNU_MBIND segments in
executable and shared objects:

static int
callback (struct dl_phdr_info *info, size_t size, void *data)
{
  Compute the load address of the current module.
  if info->dlpi_addr == the load address of the current module
    {
      check ELF program headers and process GNU_MBIND segments
      return 1;
    }

  return 0;
}

static void
call_gnu_mbind_setup (void)
{
  dl_iterate_phdr (callback, NULL);
}

static void (*init_array) (void)
 __attribute__ ((section (".init_array"), used))
 = &call_gnu_mbind_setup;

  reply	other threads:[~2017-03-31 15:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01  0:00 H.J. Lu
2017-01-01  0:00 ` Suprateeka R Hegde
2017-01-01  0:00   ` H.J. Lu
2017-01-01  0:00     ` Suprateeka R Hegde
2017-01-01  0:00       ` H.J. Lu
2017-01-01  0:00         ` Carlos O'Donell
2017-01-01  0:00           ` Suprateeka R Hegde
2017-01-01  0:00             ` H.J. Lu
2017-01-01  0:00               ` Suprateeka R Hegde
2017-01-01  0:00                 ` H.J. Lu
2017-01-01  0:00                   ` H.J. Lu
2017-01-01  0:00                     ` Suprateeka R Hegde
2017-01-01  0:00                       ` H.J. Lu
2017-01-01  0:00                         ` Suprateeka R Hegde
2017-01-01  0:00                           ` H.J. Lu
2017-01-01  0:00                             ` Suprateeka R Hegde
2017-01-01  0:00                               ` H.J. Lu
2017-01-01  0:00                                 ` Suprateeka R Hegde
2017-01-01  0:00                                   ` H.J. Lu
2017-01-01  0:00                                     ` Suprateeka R Hegde
2017-01-01  0:00                                       ` H.J. Lu [this message]
2017-01-01  0:00                     ` Florian Weimer
2017-01-01  0:00                       ` H.J. Lu
2017-01-01  0:00                         ` Florian Weimer
2017-01-01  0:00                           ` H.J. Lu
2017-01-01  0:00                             ` Florian Weimer
2017-01-01  0:00                               ` H.J. Lu
2017-01-01  0:00 ` Carlos O'Donell
2017-01-01  0:00   ` H.J. Lu
2017-01-01  0:00     ` Carlos O'Donell
2017-01-01  0:00       ` H.J. Lu
2017-01-01  0:00         ` Florian Weimer
2017-01-01  0:00           ` H.J. Lu

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=CAMe9rOoQUFJBmcBp-3vdi-MTWq_K+3z+9sfD3os7r_OTaRnVkQ@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=carlos@redhat.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=hegdesmailbox@gmail.com \
    /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).