190101 Tuesday — Other code pages

190101. Other code pages.

OldCoder's GitHub repos are located at:

https://github.com/oldcoder/

The projects at GitHub were largely stopped by the 2012 to 2013 Gag Order cases. However, the smaller projects will be useful to new developers as sample code.

The MURB Hack9 page may be viewed at:

https://haggishell.com/murb/hack9/

A few additional bits and pieces are provided below.

180803 Friday — bytehisto utility

180803. OldCoder bytehisto utility.

This post provides the latest release of the OldCoder bytehisto utility in both text (runnable) and HTML (browseable) formats.

To view the source code in text, or to download it, right-click or left-click on the following link as is appropriate for your browser:

bytehisto.txt

To browse the source code in HTML, visit the following link instead:

bytehisto.html

For an explanation of the utility, see the comments near the top of the source code.

180701 Sunday — Port of elfutils to musl

180701. Port of elfutils to musl.

musl elfutils

This post is for those who know what "elfutils" and "musl" are and would like to get one into the other.

I've ported "elfutils" 0.173, which seems to be the latest official release as of 180701, to musl 1.1.19.

Other ports exist. However, most are distro-specific or for older releases of "elfutils". This port should be useful to developers working on their own "musl"-based distros.

This wasn't a small task.

elfutils is madness
elfutils is horror
elfutils is descent into pit
Into musl elfutils does not fit

So, I'll share the resulting patch file and procedure with others interested in "musl".

Questions and comments may be sent by email to: oldcoder@yahoo.com


For me, at any rate, the patch file and procedure produce a clean "elfutils" build including executables and both static and dynamic libraries.

The "gcc" and "binutils" used were releases 6.4.0 and 2.27, respectively, as built by Rich Felker's "musl" cross make toolkit located at:

https://github.com/richfelker/musl-cross-make

You can download all of the special files required, not including musl cross make, in a single ZIP archive at this link:

http://haggishell.com/elfutils-oldcoder-180701.zip

The link will probably change later.

The ZIP file contains these files. You can download the ZIP file at this link. Or you can get the files inside it at the links below. Text files linked here have been renamed to "*.txt".


Name Notes
README A copy of this post
argp-standalone-1.3.tar.gz "libargp" library sources
argp-standalone-1.3.tar.gz.url URL where I obtained preceding
elfutils-0.173.tar.bz2 "elfutils" 0.173 sources
elfutils-0.173.tar.bz2.url URL where I obtained preceding
libargp-01-alpine-funcdef.patch An Alpine patch for argp*
libargp-02-alpine-gnu89.patch Ditto
musl-elfutils-180701.patch My "musl-elfutils" patch
obstack-git-180701.tar.bz2 "obstack" library sources
obstack-git-180701.tar.bz2.url URL where I obtained preceding

Here's the "build" procedure. You'll most likely need to make changes based on your OS configuration.

1. Start with a distro based on "musl" 1.1.19, "gcc" 6.4.0 or 7.2.0 or above, and "binutils" 2.27 or 2.28.

You'll need a full standard development toolkit, including recent releases of "autoconf", "automake", and related packages. "bzip2", "xzutils", and "zlib" libraries and header files as well.

In the following sections, you can change the PREFIX setting used, but two rules apply:

* The same PREFIX setting should be used in each script
* $PREFIX/include should be a directory that "gcc -I" knows about

2. You may, or may not, need to rebuild various existing libraries with either or both of these two changes:

* Use the "gcc -fPIC" flag
* Build both static and dynamic libraries

Skip this part initially. If you get error messages later related to linking with existing libraries, come back to this point and decide whether or not rebuilds might help.

3. If your distro doesn't provide the "libargp.*" library and associated header files, build and install "argp-standalone". Use the two Alpine patches provided.

The following script may work, with changes:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

#!/bin/bash -e PREFIX=/usr/local mkdir -p $PREFIX/{bin,sbin,include,lib} # rm -fr argp-standalone-1.3 tar zxf argp-standalone-1.3.tar.gz pushd argp-standalone-1.3 patch -p1 < ../libargp-01-alpine-funcdef.patch patch -p1 < ../libargp-02-alpine-gnu89.patch touch compile autoreconf export CFLAGS="-fPIC -O2" # ./configure --prefix=$PREFIX make mv argp*.h $PREFIX/include/ mv libargp.a $PREFIX/lib/ popd

Warning: This package shouldn't be installed on a "glibc"-based system unless you take steps to prevent it from being used without special "gcc -I" and "ld -L" switches.

Even on a "musl"-based system, this package may break GNU "tar". If this happens, you'll probably be able to fix the problem by fiddling with "tar" Makefiles.

4. If your distro doesn't provide the "libobstack.*" library and the associated header file, build and install "obstack". The following script may work, with changes:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

#!/bin/bash -e PREFIX=/usr/local mkdir -p $PREFIX/{bin,sbin,include,lib} # rm -fr obstack-git-180701 tar jxf obstack-git-180701.tar.bz2 pushd obstack-git-180701 ./bootstrap.sh export CFLAGS="-fPIC -O2" # ./configure --prefix=$PREFIX make && make install popd

5. Edit "musl-elfutils-180701.patch". Look for this part:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

+argp_LDADD="-L/usr/local/lib -Wl,-R/usr/local/lib ... ... +obstack_LDADD="-L/usr/local/lib -Wl,-R/usr/local/lib ...

If "libargp.* is installed somewhere besides "/usr/local/lib", modify the "argp_LDADD" line appropriately.

If "libobstack.* is installed somewhere besides "/usr/local/lib", modify the "obstack_LDADD" line appropriately.

6. Build and install "elfutils". The following script may work, with changes:

Your phone or window is too narrow to show the code. If it's a phone, try rotating the phone or switching to a PC.

#!/bin/bash -e PREFIX=/usr/local mkdir -p $PREFIX/{bin,sbin,include,lib} # rm -fr elfutils-0.173 tar jxf elfutils-0.173.tar.bz2 cd elfutils-0.173 patch -p1 < ../musl-elfutils-180701.patch autoreconf # export LIBS="-L$PREFIX/lib -Wl,-R$PREFIX/lib -lbz2 -lz" export CFLAGS="-fPIC -O2" # ./configure --prefix=$PREFIX make && make install

© 2012-2019 Robert Kiraly aka OldCoder and BoldCoder    |  Privacy policy    |  Contact   |  Notices