4
7
Fork
You've already forked dev86
5

ar86 doesn't recognise object files produced by as86 #16

Open
opened 2026年04月25日 23:58:56 +02:00 by tlid · 1 comment
Contributor
Copy link

dev86 commit: 2f41e7dd02
host machine: 6.12.74+deb13+1-amd64

I'm currently trying to set up a cross-compiler toolchain to allow me to build the MINIX 1 tree, targeting an 8088 XT, on a modern x86-64 machine. I've run into some issues when trying to create a library with ar86. Here's a minimal example:

TOOLS_DIR=~/dev86/bin
CC=$TOOLS_DIR/bcc
AS=$TOOLS_DIR/as86
AR=$TOOLS_DIR/ar86
SOURCE=./foo.c
AS_OUT=./foo.s
OBJ_OUT=./foo.o
LIBFILE=./libfoo.a
cat << EOF > $SOURCE
int foo(void) {
 return 42;
}
EOF
$CC -0 -S -ansi $SOURCE -o $AS_OUT
$AS -0 -o $OBJ_OUT $AS_OUT
rm -f $LIBFILE
$AR r $LIBFILE $OBJ_OUT
echo "adding symbol index"
$AR s $LIBFILE

It produces the following output, throwing an error when trying to add the symbol index to the archive:

$ bash run.sh 
Creating archive file `./libfoo.a'
adding symbol index
~/dev86/bin/ar86: bad format (not an object file) in ./libfoo.a(foo.o)

I will continue to look further into this and don't mind submitting a patch if needed, but any help/ideas would be appreciated

dev86 commit: 2f41e7dd020dd0997bad64094ad8e416ea5ad1ad host machine: 6.12.74+deb13+1-amd64 I'm currently trying to set up a cross-compiler toolchain to allow me to build the MINIX 1 tree, targeting an 8088 XT, on a modern x86-64 machine. I've run into some issues when trying to create a library with `ar86`. Here's a minimal example: ```bash TOOLS_DIR=~/dev86/bin CC=$TOOLS_DIR/bcc AS=$TOOLS_DIR/as86 AR=$TOOLS_DIR/ar86 SOURCE=./foo.c AS_OUT=./foo.s OBJ_OUT=./foo.o LIBFILE=./libfoo.a cat << EOF > $SOURCE int foo(void) { return 42; } EOF $CC -0 -S -ansi $SOURCE -o $AS_OUT $AS -0 -o $OBJ_OUT $AS_OUT rm -f $LIBFILE $AR r $LIBFILE $OBJ_OUT echo "adding symbol index" $AR s $LIBFILE ``` It produces the following output, throwing an error when trying to add the symbol index to the archive: ``` $ bash run.sh Creating archive file `./libfoo.a' adding symbol index ~/dev86/bin/ar86: bad format (not an object file) in ./libfoo.a(foo.o) ``` I will continue to look further into this and don't mind submitting a patch if needed, but any help/ideas would be appreciated
tlid changed title from (削除) ar86 doesn't recognise object files projects by as86 (削除ここまで) to ar86 doesn't recognise object files produced by as86 2026年04月26日 00:03:38 +02:00
Author
Contributor
Copy link

I originally looked into this because I thought that ld86 was a single-pass linker, turns out it's a two-pass linker. Since it builds a full symbol table at link time, there doesn't appear to be a need to embed a symbol table in the archive. We can just build archives without the -s modifier. I confirmed in a test example that linking is successful irrespective of the order I place objects in a library, even without an index in the archive.

Would be nice to know why the error above occurs though. From looking through the code it appears that, when adding a symbol table, ar86 expects member headers to be in the a.out format rather than the object file headers generated by as86. What's the reason for this?

I originally looked into this because I thought that `ld86` was a single-pass linker, turns out [it's a two-pass linker](https://codeberg.org/jbruchon/dev86/src/commit/2f41e7dd020dd0997bad64094ad8e416ea5ad1ad/ld/readobj.c#L14-L18). Since it builds a full symbol table at link time, there doesn't appear to be a need to embed a symbol table in the archive. We can just build archives without the `-s` modifier. I confirmed in a test example that linking is successful irrespective of the order I place objects in a library, even without an index in the archive. Would be nice to know why the error above occurs though. From looking through the code it appears that, when adding a symbol table, `ar86` expects member headers to be in the `a.out` format rather than the object file headers generated by `as86`. What's the reason for this?
Sign in to join this conversation.
No Branch/Tag specified
master
lr-checks
msdos
release
v1.0.1
v1.0
v0.16.21
v0.16.20
v0.16.19
v0.16.18
v0.16.17
v0.16.16
v0.16.15
v0.16.14
v0.16.13
v0.16.12
v0.16.9
v0.16.8
v0.16.11
v0.16.10
v0.16.7
v0.16.6
v0.16.5
v0.16.4
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.6
v0.15.5
v0.15.4
v0.15.3
v0.15.1
v0.15.0
v0.14.8
v0.14.7
v0.14.5
v0.14.3
v0.14.0
v0.13.5
v0.13.0
v0.12.4
v0.12.0
v0.0.11
v0.0.9
v0.0.8
v0.0.7
v0.0.6
v0.0.5
v0.0.4
origs
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jbruchon/dev86#16
Reference in a new issue
jbruchon/dev86
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?