System Programming

Jump to: navigation, search

Disk I/O

Memory vs. Disk Caching



MIPS ABI Additions for NPTL (TLS)

uClibc NPTL Sparc32 Porting Patch

Implementing LLVM Atomics

Pulse Audio and Userspace Soft Realtime

possible. i.e. everything returned by snd_pcm_delay() and snd_pcm_avail() is checked whether it is in specific bounds ... search for "snd_pcm_delay"/"snd_pcm_avail"/"snd_pcm_update_avail" in bugzilla."

New ISA in Qemu

Linux Glibc Dynamic Linking

LD_DEBUG=statistics /lib64/libreoffice/program/swriter # with prelink
LD_USE_LOAD_BIAS=0 LD_DEBUG=statistics /lib64/libreoffice/program/swriter # without

If you disassemble the code at &strlen, you find no code that could possibly take an argument and return a string length.

If you follow these clues around for several hours of google searching, you will find the STT_GNU_IFUNC symbol type and the assembler directive .type @gnu_indirect_function in various patches applied to the glibc code.

In those patches, you will also find that glibc now has 47,621 different versions of strlen, each optimized for a different architecture variation, because, after all, it is vital to provide a 1 nanosecond speed improvement in routines that typical programs spend 0.001% of their time in at the cost of complicating the maintenance of glibc and debuggers by a factor of at least 100.

Anyway, it seems like the dynamic linker checks for these indirect function entries when it is looking up symbols to resolve .plt entries, and when it finds one, rather than stashing the symbol value as the address of the function,it *calls* the funtion, which returns a pointer to the best version of of the 47,621 alternate strlens to use on the current architecture.

So the symbol named "strlen" is indeed a function, but it is a function of no arguments which returns a pointer to another function (the one you really want). God help us all when the security boys get wind of this dynamic linker feature - then they can randomly pick different implementations of all the glibc functions at runtime :-)."

LD: linker arguments positions, --as-needed, --copy-dt-needed-entries(--add-needed)

GCC: -{g,f}record-gcc-switches

  • gcc -grecord-gcc-switches stores them in the .debug_info section (output modified to reduce line length)
$ gcc -O2 -grecord-gcc-switches -g -o hello hello.c
$ readelf --debug-dump hello | grep DW_AT_producer
 <c>   DW_AT_producer GNU C 4.6.2 20111027 (Red Hat 4.6.2-1) -mtune=generic -march=x86-64 -g -O2
    • -g seams to imply -grecord-gcc-switches
  • gcc -frecord-gcc-switches stores them in a new .GCC.command.line section
$ gcc -O2 -frecord-gcc-switches -g -o hello hello.c
$ readelf -p .GCC.command.line hello
String dump of section '.GCC.command.line':
  [     0]  hello.c
  [     8]  -mtune=generic
  [    17]  -g
  [    1a]  -O2
  [    1e]  -frecord-gcc-switches

See Also


blog comments powered by Disqus