Asmutils HOWTO

Konstantin Boldyshev

Linux Assembly

    konst@linuxassembly.org

Version 0.6

$Date: 2001/03/18 07:08:25 $

This is the Asmutils HOWTO.

This document is to accompany asmutils, explain asmutils internals, describe how to write asmutils program and how to contribute to the project.

It targets asmutils developers and advanced users striving for the secret lore of the assembly entity.


Table of Contents
1. Introduction
1.1. Legal blurb
1.2. Before you begin
1.3. Compiling asmutils
2. Program layout
3. Include files description
3.1. system.inc
3.2. includes.inc
3.3. syscall.inc
3.4. elf.inc
4. Debugging your code
4.1. ald
4.2. gdb
4.3. strace
5. Contribution guidelines
5.1. First step
5.2. Source code requirements
5.3. Last step
5.4. Porting
6. Optimization, tips and tricks
A. History
B. Acknowledgements
C. Endorsements

1. Introduction

1.1. Legal blurb

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License Version 1.1; with no Invariant Sections, with no Front-Cover Texts, and no Back-Cover texts.

1.2. Before you begin

I assume you are familiar with Unix and assembly language to an extent when you are able to understand what is written here. If you are unable to comprehend most of what is written here, probably this manuscript is not for you, sorry.

I expect that you will dig in and examine source code of asmutils. This document is not intended to replace the source, its goal is only to accompany asmutils source and explain several unclear moments. Again, examine ALL source code. Look how command line parsing is done, how conditional assembly for different kernel versions is done and so on -- I am not going to explain all and everything here.

This document deals with compiling, developing, debugging, contributing issues, it shows some tricks you can use; also it describes a set of macros I've developed to write fast and readable: they are hiding from you unneeded details, and take care of optimization.

You may also want to read other documentation represented at the Linux Assembly site to get better general (not asmutils specific) understanding of asmutils source code.

1.3. Compiling asmutils

Asmutils are build with the usual compile suite and nasm. Except nasm you will need GNU make, ld, sh, ln, rm, possibly strip and possibly something else, depending on your OS.

Preferred program versions are:

  • nasm 0.98

  • ld from GNU binutils 2.9 (on Linux)

  • GNU make 3.79

Older/newer/other versions may work too. GNU make is required, on BSD systems it is usually called gmake, and can be found in ports collection.

All compile-time configuration is in the MCONFIG file, which has enough comments to figure out what you can do. You can try to fallback to libc functions instead of using direct system calls by defining OS=LIBC in MCONFIG if your really want to do so; then you will also need gcc and libc headers.

Note: several utils (cpuinfo, eject, httpd, kill, etc) have their own additional configuration in the source code.