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

Re: RFC: ABI support for special memory area

Here is the my current proposal.

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.

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)

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

int __gnu_mbind_setup (unsigned int type, void *addr, size_t length);

It sets up special memory area of 'type' and 'length' at 'addr' where
'addr' is a multiple of page size.  It returns zero for success, positive
value of ERRNO for non-fatal error and negative value of ERRNO for fatal

After all shared objects and the executable file are loaded, relocations
are processed, for each GNU_MBIND segment in a shared object or the
executable file, run-time loader calls __gnu_mbind_setup with type,
address and length.  The default implementation of __gnu_mbind_setup is

__gnu_mbind_setup (unsigned int type, void *addr, size_t length)
  return 0;

which can be overridden by a different implementation at link-time.