bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/12565] NOLOAD sections empty


From: jifl-bugzilla at jifvik dot org
Subject: [Bug ld/12565] NOLOAD sections empty
Date: Tue, 15 Mar 2011 19:52:42 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=12565

--- Comment #2 from Jonathan Larmour <jifl-bugzilla at jifvik dot org> 
2011-03-15 19:52:27 UTC ---
Yes here's a definite way to reproduce. I can definitely confirm it's
platform-independent in fact as I've reproduced it with native Linux. Here it
is in annoying detail purely for completeness. Take shortcuts where you like:

1. Build binutils for native linux (I used CVS of 2011-03-10), and put the bin/
directory at the head of your PATH:

mkdir -p /tmp/b12565/build
cd /tmp/b12565/build
~/src/binutils/src/configure --prefix=/tmp/b12565/install
make all install
export PATH=/tmp/b12565/install/bin:$PATH

2. Create a helloworld app just for testing:
mkdir /tmp/b12565/c
cd /tmp/b12565/c
cat > helloworld.c <<EOF
#include <stdio.h>
int main(int argc, char *argv[])
{
  printf("Hello world!\n");
  return 0;
}
EOF

3. Build it with full verbosity, and with -g:
gcc -g -o helloworld helloworld.c -v -Wl,-v --save-temps

4. As a baseline, look at its .debug_info section:
readelf -x .debug_info helloworld | less

Notice it has useful stuff in.

5. Extract the default linker script with:
ld --verbose | sed -n '/^======/,/^======/p' |egrep -v ^====== > script.ld 

6. Modify the .debug_info line of script.ld to add NOLOAD:
  .debug_info     0 (NOLOAD) : { *(.debug_info .gnu.linkonce.wi.*) }

7. Cut'and'paste the link line (invoking ld) you will have seen in step (3) but
appending -T./script.ld

8. Look at .debug_info again, and you'll see it is zeroed:
readelf -x .debug_info helloworld | less


Again, as a reminder, I'm just using .debug_info as an example section which
isn't meant to be loaded. The problem is not specific to it of course.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]