statifier — Dynamic to Static

Homepage of statifier.

Statifier create from dynamically linked executables and all it\’s libraries one file.
This file can be copied and run on another machine without need to drag all it\’s libraries.

Dynamically linked executables are smaller then statically linked.
From the other side dynamically linked executables use shared libraries compiled in PIC (position independend code) which is slower than \”normal\” one.

Files, created by statifier (\”pseudo-static\”) combine disadvantages of both of them:

  • Huge – much bigger than statically linked
  • Still use PIC code

So, why one will use it ?
Ok, \”pseudo-static\” files have some advantages too:

  • Everything in one file – so distributing is simple
  • Same file can be used for computers with different libraries\’ versions
  • Faster startup

But all these one can got with usual static files.
So, why use statifier and huge \”pseudo-static\” executables instead of static ?

  • there is no source code available
  • there is no compiler (or build-chain) available
  • static link does not work or it\’s not obvious how do it
  • to preserve memory layout – static link will change it and may \”wake-up\” hidden bugs
  • for \”permanent link\” LD_PRELOAD library into executable

Supported platforms

  • linux x86
  • linux x86_64
  • linux alpha

Short Information about loaded kernel modules

There are couple of ways you can find the information on the loadable kernel modules. All these would always involve calling lsmod to get the loaded kernel modules and then calling modinfo to get the info on the loaded modules. I will show you with examples:

$ lsmod
Module                  Size  Used by
cdc_acm                19616  0
vfat                    8744  9
fat                    41836  1 vfat

The above output is for the list of the modules loaded on the kernel.

$ modinfo vfat

filename:       /lib/modules/2.6.31.5-127.fc12.i686.PAE/kernel/fs/fat/vfat.ko
author:         Gordon Chaffee
description:    VFAT filesystem support
license:        GPL
srcversion:     48F6DF1D674F0E1325466C9
depends:        fat
vermagic:       2.6.31.5-127.fc12.i686.PAE SMP mod_unload 686

modinfo will list the filename, authour and other related info for the modules. So if you wanted to get the info for all the modules, then the easiest way would be to do :

lsmod|xargs modinfo

But as you can see, this will list all the info on  the module, which is not really required. So there were couple of posts on commandlinefu, that takes care of displaying only the required information, viz. filename, authour and dependency. Here are the commands:

lsmod | sed \’1d\’ | cut -d\’ \’ -f1 | xargs modinfo | egrep \’^file|^desc|^dep\’ | sed -e\’/^dep/s/$/\\n/g\’

Quite raw method where we grep the required fields and susbstitute the end with newline for the last patter \":)\"

lsmod | sed -e \’1d\’ -e \’s/\\(\\([^ ]*\\) \\)\\{1\\}.*/\\2/\’ | xargs modinfo | sed -e \’/^dep/s/$/\\n/g\’ -e \’/^file/b\’ -e \’/^desc/b\’ -e \’/^dep/b\’ -e d

Quite same as above with only exception of using one sed command rather than egrep and sed.

modinfo $(cut -d\’ \’ -f1 /proc/modules) | sed \’/^dep/s/$/\\n/; /^file\\|^desc\\|^dep/!d\’

Directly using the modinfo commands without xargs and passing the arguments with cut command and then using sed to display only the required fields.

awk \'{print $1}\’ \”/proc/modules\” | xargs modinfo | awk \’/^(filename|desc|depends)/\’

using awk to check the /proc/modules and then displaying the fields with awk

\"Reblog

Seders\’s grab bag – Tutorials

http://sed.sourceforge.net/grabbag/tutorials/

seder\’s grab bag

Sed Tutorials

If you have written anything about sed – whether an introduction, how sed got you out of a real-life situation, or perhaps an advanced technique you\’ve discovered – you may like have your work published here. Your contribution will be very welcome.

Intros

sed one-liners (18kb)
The essential, official compendium of useful sed one-liners. Organised into sections by usage, such as file spacing, line numbering, selective line removal/deletion and optimisation.
The sed FAQ v15 (168kb)
The official, indispensable sed FAQ. This file was recently updated. Also available as ZIP-compressed HTML (75kb). The latest version can always be found on the author\’s site.
Another sed FAQ
And here is another sed FAQ, by a different person.
Do it with sed (51kb)
By Carlos Jorge G.Duarte. A comprehensive and leisurely résumé. Contains many interesting examples, and a useful command summary.
SED – A Non-interactive Text Editor (32kb)
By Lee E. McMahon (1978). The definitive introduction, this well-known document used to be distributed with UNIX systems. It examines each of sed\’s functions in depth and includes useful examples.
Program state in sed (4kb)
By Greg Ubben. A nice introduction to advanced sed, showing how to mantain state across lines.
Introduction to Unix\’s SED editor
By F. Curtis Michel, Rice University, Houston.

Advanced topics

Using sed to create a book index (12kb)
Eric Pement of Cornerstone magazine shows how he used sed and other utilities to massage an unsorted list of book references into an index.
Using lookup tables with s/// (9kb)
Part 1 of Greg Ubben\’s analysis of a complex sed script he wrote to sort, delimit and number an input file containing tabulated data. Lookup tables are a powerful technique for the serious seder\’s armoury.
A lookup-table counter (11kb)
Part 2 of Greg\’s script analysis looks at how he implemented a counter using lookup tables. This complex problem is described step by step from the basics, following through Greg\’s reasoning until we finally reach the solution.
Counting words (3kb)
Adding a list of decimals (3kb)
Greg explains how to count words and how to add a list of decimal numbers using a simple analog format.

Miscellaneous

When seemingly obvious scripts fail (2kb)
sed FAQ author Eric Pement explains why sometimes you cannot get your one-liner right.
Towers of Hanoi with sed (18kb)
A document which shows how to make sed solve the classic Towers of Hanoi game.
Proposals for a custom sed (18kb)
A list of proposals to make sed more versatile without sacrificing its speed and overall philosophy. I implemented a few of these in super-sed and in GNU sed 4.0.
\"Reblog