This is the mail archive of the 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: __curbrk (and &_end)

On Tue, Feb 17, 2004 at 06:21:30PM -0800, Roland McGrath wrote:
> If you want to refer to the program's _end, you need to make sure
> the version script for building exports _end such that its
> references will be resolved by the dynamic linker and matched up with the
> program's definitions.  However, I think relying on _end is probably not
> the way to go.  You can instead look at the PT_LOAD headers to find the end
> of the data segment.

Thanks Roland, that worked fine (although I'll have to RTFM a bit before I
can implement it with PT_LOAD).

The resulting code is pretty generic, and I think it could be added to
sysdeps/generic/brk.c. Would you like me to send a patch for that? It'd
roughly look like:

__brk (void *addr)
#ifdef SYS_break
  if (__curbrk == NULL)
    __curbrk = &_end;
  if (syscall (SYS_break, addr) == -1)
  __set_errno (ENOSYS)
  return -1;

Robert Millan

"[..] but the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery; wherefore he
gives and hoards not, and is free from care, passing ever on to some new work."

 -- J.R.R.T., Ainulindale (Silmarillion)

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