This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: Question about elf data segment address adjustment




On 10/19/2017 11:44 AM, Nick Clifton wrote:
Hi Douglas,

In ld/scripttempl/elf.sc about line 562 there's a comment that pre-dates the 1999 sourceware import, so I can't track it down.

Searching through the old CVS logs, I found this:

   revision 1.32
   date: 1996/02/15 20:28:54;  author: ian;  state: Exp;  lines: +2 -14
	* scripttempl/elf.sc: Don't skip a page in virtual memory space if
	the text segment ends exactly on a page boundary.


I can post a powerpc-vxworks7 example, but the same problem can be seen looking at a map file on x86-64-linux. The intent of this enhancement of 1996 seems to have been lost somewhere along they way.

A trivial "C" program:
--------------
$ cat foo3.c
#include <stdio.h>

extern int my_global;

void
main ()
{
  printf ("%d\n", my_global);
}
----------------
$ cat bar3.c
int my_global = 0;
----------------
$ gcc -c foo3.c
$ gcc -c bar3.c
$ gcc -o foo3 foo3.o bar3.o -Wl,-M >foo3.map

Shows that there's a huge chunk of wasted space if I'm understanding the map file correctly. Note the gap between .eh_frame and .exception_ranges

....

.eh_frame 0x0000000000400700 0x4 /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o
 *(.eh_frame.*)

.gcc_except_table
 *(.gcc_except_table .gcc_except_table.*)

.gnu_extab
 *(.gnu_extab*)

.exception_ranges
 *(.exception_ranges .exception_ranges*)
0x0000000000600e10 . = DATA_SEGMENT_ALIGN (0x200000, 0x1000)

....


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