This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Encoding page size in the ELF header


On Sat, Sep 26, 2015 at 07:13:00PM -0400, Frank Ch. Eigler wrote:
> 
> fweimer wrote:
> 
> > [...]
> >> Can't the application just call getpagesize(), and then use that to
> >> decide how to make .data read-only?
> >
> > The idea is to do something like this:
> > #define PAGE_SIZE 4096
> > union {
> >   int critical_data;
> >   char pad[PAGE_SIZE];
> > } u __attribute__((aligned(PAGE_SIZE))) = {};
> >
> > And then call mprotect(&u, PAGE_SIZE, PROT_READ) after initialization.
> 
> Could the app more portably use
> 
> int critical_data __attribute__((section(".data.critical")));
> 
> and maybe a linker script widgetry to assure padding & fetch
> base-addresses, and then mprotect it that way?  It would become
> independent of page size.

That does not eliminate the page size dependency.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]