Patches and binaries

# 4. Patches and binaries

Contents of this section

At this point in the proceedings, you can, if you like, stop. You have installed everything necessary to compile and run ELF programs.

You may wish to rebuild some programs in ELF, either for purposes of `neatness' or to minimise memory usage. For most end-user applications, this is pretty simple; some packages however do assume too much about the systems they run on, and may fail due to one or more of:

- Different underscore conventions in the assembler: in an a.out executable, external labels get `_` prefixed to them; in an ELF executable, they don't. This makes no difference until you start integrating hand-written assembler: all the labels of the form `_foo` must be translated to `foo`, or (if you want to be portable about it) to `EXTERNAL(foo)` where `EXTERNAL` is some macro which returns either its argument (if `__ELF__` is defined) or `_` concatenated with its argument if not.
- Differences in libc 5 from libc 4. The interface to the locale support has changed, for one.
- The application or build process depending on knowledge of the binary format used --- emacs, for example, dumps its memory image to disk in executable format, so obviously needs to know what format your executables are in.
- The application consists of or includes shared libraries (X11 is the obvious example). These will obviously need changes to accomodate the different method of shared library creation in ELF.

Anyway, here are two lists: the first is of programs that needed changing for ELF where the changes have been made (ie that you will need new versions of to compile as ELF), and the second is of programs that still need third-party patches of some kind.

## 4.1 Upgrade:

- Dosemu. Modulo the three or four cuurrent dosemu development trees (don't ask, just join the linux-msdos mailing list), dosemu runs with ELF. You'll need to monkey with the Makefile. Current versions of dosemu are available from ftp://tsx-11.mit.edu/pub/linux/ALPHA/dosemu/
- Emacs. Emacs has a rather odd build procedure that involves running a minimal version of itself, loading in all the useful bits as lisp, then dumping its memory image back to disk as an executable file. (FSF) Emacs 19.29 and XEmacs 19.12 (formerly Lucid Emacs) can both detect whether you are compiling as ELF and Do The Right Thing automatically.
- MAKEDEV. In some incarnations, this utility removes existing entries for devices before recreating them. This is Bad News if it happens to touch `/dev/zero`, as said device is necessary to the operation of all ELF programs. See the util-linux package(q.v.) for a fixed version.
- perl 5.001. Perl 5.001 plus the ``official unofficial'' patches a-e will compile unchanged on an ELF system, complete with dynamic loading. The patches are available from `ftp.metronet.com` or `ftp.wpi.edu`
- The `cal` program in util-linux 2.2 doesn't work. Upgrade to version 2.4 or later.
- XFree86. XFree86 3.1.2 comes in both a.out and ELF formats. `ftp` to `ftp.xfree86.org`, read the `too many users' message that you are almost guaranteed to get, and pick the closest mirror site network-wise to you. Once you have the contents of the `common` and `elf` directories, you must edit `/usr/X11R6/lib/X11/config/linux.cf` to change the lines saying

  > `

  >     #define LinuxElfDefault         NO
  >     #define UseElfFormat            NO

  > `

  to say `YES` instead. Otherwise an xpm build will attempt to do odd stuff with `jumpas` and its associated relics of the past.
- Mosaic. I don't have the facilities to build this myself, but the Mosaic 2.7b1 binary available from NCSA comes in ELF. It has been linked against an odd X setup though, with the result that on normal systems it will complain about not finding `libXpm.so.4.5`. The simple fix is to edit it carefully with emacs or another editor that copes with binary files. Find the occurence of the string `libXpm.so.4.5ˆ@` (where `ˆ@` is a NUL --- ASCII zero --- character), delete the `.5` and add two more characters after the NUL to aviod changing the file length.

## 4.2 Patch

- e2fsutils. The Utilities for the Second Extended File System need a patch from ftp://ftp.ibp.fr/pub/linux/ELF/patches/e2fsprogs-0.5b.elf.diff.gz to compile correctly as a shared library. Remy Card says ``This is the ELF patch which will probably be included in the next release of e2fsck and co''
- file. This works anyway, but can be improved: http://sable.ox.ac.uk/~jo95004/patches/file.diff adds support for identifying stripped and mixed-endian ELF binaries.
- The Kernel. As from at least 1.3.8, the development 1.3 series have a `make config` option to build using ELF tools. If you are using the 1.2 series, you have two options:
  1. Patch the Makefile slightly to use the a.out compiler. Just change the `CC` and `LD` definitions to be

     > `

     >     LD      =ld -m i386linux
     >     CC      =gcc -b i486-linuxaout -D__KERNEL__ -I$(TOPDIR)/include

     > `

     Alternatively,
  2. Apply H J Lu's patch which allows compiling the kernel in ELF (and also adds the ability to do ELF core dumps).
  Let me reiterate that neither of these is necessary for the 1.3 series.
- `ps` (procps-0.97) The `psupdate` program needs a patch to work if you have compiled the kernel as ELF. It's available in linux.nrao.edu:/pub/people/juphoff/procps , both as a patch to vanilla 0.97 and as an entire tar-file. A new version of procps is expected to be released soon with this patch in place, so if you can find procps 0.98 by the time you read this, this patch will probably be obsolete.

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter