This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

Re: data_start, __data_start


Hi Hans,

: Should ld on Linux define either or both of data_start and __data_start?

I do not know of any standard that requires it.

: I maintain a garbage collecting allocator that's used with a number
: of applications including gcj.  It needs to find the bounds of
: writable data segments, especially the main one, since it needs to
: scan those for pointers to collectable memory.  Under Linux, it
: currently it finds the beginning of the main .data segment by
: looking for either data_start or __data_start, whichever one is
: defined.  I arrived at this "solution" after determining that Linux
: distributions were inconsistent in which one they defined.  

: Unfortunately, it now appears that there is at least one
: distribution (RH6.2for Alpha, possibly others) that defines neither.

: Questions:  
: 1) Is this a bug in the Linux distribution(s)? 

Not a bug, but it might be considered an omission.

: Is this the wrong place to ask this question?

Actually it is a good place to start talking about the topic at least.
It would probably be good to include the linux kernel folk as well, so
I am CC'ing this reply to Linus, in case he agrees with me.

: 2) Is there a better way to determine the beginning of the main data
: segment?  Note that the program asking the question, i.e. the collector
: itself, may reside in a shared library.  This precludes all sorts of
: plausible solutions that we tried in the past.  (The best known generic
: alternatives seem to be to start at &_end and walk backwards until you get a
: page fault, or to read /proc/self/maps.  The code to do either of those is
: basically already there, but neither seems ideal.)

Can you get at executable image on disk ?  If so you could parse the
ELF headers, locate the data segments and work everything out from
there.

: 3) Is there any hope of standardizing the linker scripts again?

This is more of a kernel issue than a binutils issue.  It is quite
straightforward to add this symbol to a linker script, it just needs
the official blessing of the Linux developers, plus making sure that
all of the linker scripts involved do get updated.

: I would vote for the old name __data_start, since the user can 
: legitimately define the symbol data_start, which would break the
: collector.  This should stay out of the user namespace.

Agreed.

Cheers
	Nick

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