Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce number of sections in loader.elf #26

Closed
nyh opened this issue Aug 1, 2013 · 1 comment
Closed

Reduce number of sections in loader.elf #26

nyh opened this issue Aug 1, 2013 · 1 comment

Comments

@nyh
Copy link
Contributor

nyh commented Aug 1, 2013

Right now, our loader.elf has more than 3000 (!) ELF sections (see bjdump -h build/release/loader.elf). All these sections subdivisions waste space (about half a megabyte), and the subdivision of the "text" sections causes "perf kvm"'s output to be unreadable.

The solution is to fix arch/x64/loader.ld
The most important part is to merge the .text.* sections. A patch for this would be (Avi already sent a similar patch):

-    .text : { *(.text) *(.text.hot) *(.text.unlikely) *(.text.fixup) } :text
+    .text : {
+        *(.text.hot .text.hot.*)
+        *(.text.unlikely .text.unlikely.* .text.*_unlikely)
+        *(.text.fixup)
+        *(.text.startup .text.startup.*)
+        *(.text .text._*)
+    } :text

There are also hundreds of data sections, the following patch correctly merges them:

-    .data : { *(.data) } :text
+/*    .data : { *(.data) } :text */
+    .data.rel.ro : {
+        *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
+        *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
+    } : text
+    .data : { *(.data .data.* .gnu.linkonce.d.*) } :text

What remain are several hundred .gcc_except_table.* sections. An attempt to merge them with:

+    .gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } : text

Miserably fails - the generated code hangs when using timers, I still have no idea why (most benchmarks fail, try for example tst-pipe.so).
Interestingly, if in the above line I replace "text" by "dynamic", I get a linker warning, but everything works (the sections are merged, and the resulting code appears to work). have no idea why.

penberg pushed a commit that referenced this issue Aug 26, 2013
Fix mincore() to deal with unmapped addresses like msync() does.

This fixes a SIGSEGV in libunwind's access_mem() when leak detector is
enabled:

   (gdb) bt
  #0  page_fault (ef=0xffffc0003ffe7008) at ../../core/mmu.cc:871
  #1  <signal handler called>
  #2  ContiguousSpace::block_start_const (this=<optimized out>, p=0x77d2f3968)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/oops/oop.inline.hpp:411
  #3  0x00001000008ae16c in GenerationBlockStartClosure::do_space (this=0x2000001f9100, s=<optimized out>)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/memory/generation.cpp:242
  #4  0x00001000007f097c in DefNewGeneration::space_iterate (this=0xffffc0003fb68c00, blk=0x2000001f9100, usedOnly=<optimized out>)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/memory/defNewGeneration.cpp:480
  #5  0x00001000008aca0e in Generation::block_start (this=<optimized out>, p=<optimized out>)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/memory/generation.cpp:251
  #6  0x0000100000b06d2f in os::print_location (st=st@entry=0x2000001f9560, x=32165017960, verbose=verbose@entry=false)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/runtime/os.cpp:868
  #7  0x0000100000b11b5b in os::print_register_info (st=0x2000001f9560, context=0x2000001f9740)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:839
  #8  0x0000100000c6cde8 in VMError::report (this=0x2000001f9610, st=st@entry=0x2000001f9560)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:551
  #9  0x0000100000c6da3b in VMError::report_and_die (this=this@entry=0x2000001f9610)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:984
  #10 0x0000100000b1109f in JVM_handle_linux_signal (sig=11, info=0x2000001f9bb8, ucVoid=0x2000001f9740,
      abort_if_unrecognized=<optimized out>)
      at /usr/src/debug/java-1.7.0-openjdk-1.7.0.25-2.3.12.3.fc19.x86_64/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:528
  #11 0x000000000039f242 in call_signal_handler (frame=0x2000001f9b10) at ../../arch/x64/signal.cc:69
  #12 <signal handler called>
  #13 0x000000000057d721 in access_mem ()
  #14 0x000000000057cb1d in dwarf_get ()
  #15 0x000000000057ce51 in _ULx86_64_step ()
  #16 0x00000000004315fd in backtrace (buffer=0x1ff9d80 <memory::alloc_tracker::remember(void*, int)::bt>, size=20)
      at ../../libc/misc/backtrace.cc:16
  #17 0x00000000003b8d99 in memory::alloc_tracker::remember (this=0x1777ae0 <memory::tracker>, addr=0xffffc0004508de00, size=54)
      at ../../core/alloctracker.cc:59
  #18 0x00000000003b0504 in memory::tracker_remember (addr=0xffffc0004508de00, size=54) at ../../core/mempool.cc:43
  #19 0x00000000003b2152 in std_malloc (size=54) at ../../core/mempool.cc:723
  #20 0x00000000003b259c in malloc (size=54) at ../../core/mempool.cc:856
  #21 0x0000100001615e4c in JNU_GetStringPlatformChars (env=env@entry=0xffffc0003a4dc1d8, jstr=jstr@entry=0xffffc0004591b800,
      isCopy=isCopy@entry=0x0) at ../../../src/share/native/common/jni_util.c:801
  #22 0x000010000161ada6 in Java_java_io_UnixFileSystem_getBooleanAttributes0 (env=0xffffc0003a4dc1d8, this=<optimized out>,
      file=<optimized out>) at ../../../src/solaris/native/java/io/UnixFileSystem_md.c:111
  #23 0x000020000021ed8e in ?? ()
  #24 0x00002000001faa58 in ?? ()
  #25 0x00002000001faac0 in ?? ()
  #26 0x00002000001faa50 in ?? ()
  #27 0x0000000000000000 in ?? ()

Spotted by Avi Kivity.
nyh added a commit that referenced this issue Sep 20, 2013
Add a trivial sleep() test, which sleep()s for 2 seconds, and verifies
that this finishes and has slept for roughly 2 seconds.

I used this for debugging issue #26 - the attempts there ruined timers,
and in particular this trivial test hangs, as sleep() never returns.

(A note to our future automatic testing implementor: We need to allow
for the possibility that a test doesn't cleanly fail, but rather hangs,
and consider this a failure too).

Signed-off-by: Nadav Har'El <[email protected]>
@nyh
Copy link
Contributor Author

nyh commented Nov 26, 2013

The bug that caused timers to stop working when gcc_except_table sections are merged is gone - I am guessing this was an unrelated timer bug (see commits 870d841 and 9c3308f).

Merging the separate gcc_except_table shaves about 90K from our loader-stripped.elf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant