summaryrefslogtreecommitdiffstats
path: root/usr.bin/genassym/genassym.8
blob: 5f2bb41feba3715d943c2338039630926517ddf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
.\"
.\" $FreeBSD$
.\"
.Dd December 20, 1999
.Dt GENASSYM 8
.Os
.Sh NAME
.Nm genassym
.Nd generate assembler symbols from C
.Sh SYNOPSIS
.Nm genassym
.Op Fl o Ar outfile
.Ar objfile
.Sh DESCRIPTION
The
.Nm
command is a special-purpose program to generate assembler
symbols from C code and is used to interface the low-level
assembly code with the C code.
This, for example, is used
to build a
.Fx
kernel or module.
Its
.Ar objfile
argument is the name of an ELF object file that holds the
symbol definitions.
These definitions are extracted from
the object file and written to standard output or to the
file specified with
.Ar outfile ,
suitable for inclusion in assembler source files.
.Pp
The
.Nm
command only extracts symbols from the object file if they
are prefixed by
.Nm assym_
and are global data types, whose value is the value given
to the symbol.
The following C declaration
.Bd -literal -offset indent -compact
int assym_MY_SYMBOL = 3;
.Ed
is used to create the following assembler symbol.
.Bd -literal -offset indent -compact
#define MY_SYMBOL 0x3
.Ed
Note that the size of the symbol is extracted from the
object file, which means that the symbol may have any type
that is wide enough to hold the value.
.Sh SEE ALSO
.Xr config 8
.Xr gensetdefs 8
.Sh AUTHORS
The
.Nm
command was written by
.An Marcel Moolenaar Aq marcel@FreeBSD.org
and was based on the
.Dv gensetdefs
command.
.Sh BUGS
Not all linkers store the size of the symbol in the ELF
object file.
The GNU linker for Alpha has this bug for
example (binutils 2.9.1). In those cases the size of the
symbol is assumed to be equal to the word size of the ELF
object file.
For Alpha this is 64 bits and for i386 this
is 32 bits.
.Sh HISTORY
The
.Nm
command first appeared in
.Fx 4.0 .
OpenPOWER on IntegriCloud