Skip to content

Commit f4f7d18

Browse files
author
H. Peter Anvin (Intel)
committed
error: factor out error functions into separate files
Tidy up a *lot* of code by moving error functions into separate source files. This required breaking out some of the assembler-only files into a separate library, as it conflicts with stubs in the disassembler. Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
1 parent c0e4def commit f4f7d18

File tree

15 files changed

+995
-889
lines changed

15 files changed

+995
-889
lines changed

Makefile.in

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,45 @@ NDISASM = disasm/ndisasm.$(O)
135135
PROGOBJ = $(NASM) $(NDISASM)
136136
PROGS = nasm$(X) ndisasm$(X)
137137

138+
# Objects for the local copy of zlib. The variable ZLIB is set to
139+
# $(ZLIBOBJ) if the internal version of zlib should be used.
140+
ZLIBOBJ = \
141+
zlib/adler32.$(O) \
142+
zlib/crc32.$(O) \
143+
zlib/infback.$(O) \
144+
zlib/inffast.$(O) \
145+
zlib/inflate.$(O) \
146+
zlib/inftrees.$(O) \
147+
zlib/zutil.$(O)
148+
149+
# Common library objects
150+
LIBOBJ_COM = \
151+
stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
152+
stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \
153+
\
154+
nasmlib/ver.$(O) \
155+
nasmlib/alloc.$(O) nasmlib/asprintf.$(O) \
156+
nasmlib/crc32b.$(O) nasmlib/crc64.$(O) nasmlib/md5c.$(O) \
157+
nasmlib/string.$(O) nasmlib/nctype.$(O) \
158+
nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \
159+
nasmlib/realpath.$(O) nasmlib/path.$(O) \
160+
nasmlib/filename.$(O) nasmlib/rlimit.$(O) \
161+
nasmlib/numstr.$(O) \
162+
nasmlib/zerobuf.$(O) nasmlib/bsi.$(O) \
163+
nasmlib/rbtree.$(O) nasmlib/hashtbl.$(O) \
164+
nasmlib/raa.$(O) nasmlib/saa.$(O) \
165+
nasmlib/strlist.$(O) \
166+
nasmlib/perfhash.$(O) nasmlib/badenum.$(O) \
167+
nasmlib/readnum.$(O) \
168+
\
169+
common/common.$(O) common/errstubs.$(O) \
170+
\
171+
x86/insnsa.$(O) x86/insnsb.$(O) x86/insnsn.$(O) \
172+
x86/regs.$(O) x86/regvals.$(O) x86/regflags.$(O) \
173+
x86/iflag.$(O) \
174+
\
175+
$(ZLIB)
176+
138177
# Files dependent on warnings.dat
139178
WARNOBJ = asm/warnings.$(O)
140179
WARNFILES = asm/warnings_c.h include/warnings.h doc/warnings.src
@@ -148,10 +187,8 @@ OUTPUTOBJ = \
148187
output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
149188
output/codeview.$(O)
150189

151-
# The source files for these objects are scanned for warnings
152-
LIBOBJ_W = \
153-
nasmlib/readnum.$(O) \
154-
\
190+
# Assembler-only library objects
191+
LIBOBJ_ASM = \
155192
asm/error.$(O) \
156193
asm/floats.$(O) \
157194
asm/directiv.$(O) \
@@ -165,66 +202,25 @@ LIBOBJ_W = \
165202
asm/segalloc.$(O) \
166203
asm/rdstrnum.$(O) \
167204
asm/srcfile.$(O) \
168-
\
169-
$(OUTPUTOBJ)
170-
171-
# The source files for these objects are NOT scanned for warnings;
172-
# normally this will include all generated files.
173-
# It is entirely possible that it may be necessary to move some of these
174-
# files to LIBOBJ_W, notably $(OUTPUTOBJ)
175-
LIBOBJ_NW = \
176-
stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
177-
stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \
178-
\
179205
asm/directbl.$(O) \
180206
asm/pptok.$(O) \
181207
asm/tokhash.$(O) \
182208
asm/uncompress.$(O) \
183209
\
184210
macros/macros.$(O) \
185211
\
186-
nasmlib/ver.$(O) \
187-
nasmlib/alloc.$(O) nasmlib/asprintf.$(O) \
188-
nasmlib/crc32b.$(O) nasmlib/crc64.$(O) nasmlib/md5c.$(O) \
189-
nasmlib/string.$(O) nasmlib/nctype.$(O) \
190-
nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \
191-
nasmlib/realpath.$(O) nasmlib/path.$(O) \
192-
nasmlib/filename.$(O) nasmlib/rlimit.$(O) \
193-
nasmlib/numstr.$(O) \
194-
nasmlib/zerobuf.$(O) nasmlib/bsi.$(O) \
195-
nasmlib/rbtree.$(O) nasmlib/hashtbl.$(O) \
196-
nasmlib/raa.$(O) nasmlib/saa.$(O) \
197-
nasmlib/strlist.$(O) \
198-
nasmlib/perfhash.$(O) nasmlib/badenum.$(O) \
199-
\
200-
common/common.$(O) \
201-
\
202-
x86/insnsa.$(O) x86/insnsb.$(O) x86/insnsn.$(O) \
203-
x86/regs.$(O) x86/regvals.$(O) x86/regflags.$(O) \
204-
x86/iflag.$(O) \
205-
\
206-
$(WARNOBJ)
212+
$(WARNOBJ) \
213+
$(OUTPUTOBJ)
207214

208215
# Objects which are only used for the disassembler
209216
LIBOBJ_DIS = \
210217
disasm/disasm.$(O) disasm/sync.$(O) disasm/prefix.$(O) \
218+
disasm/diserror.$(O) \
211219
\
212220
x86/insnsd.$(O) x86/regdis.$(O)
213221

214-
# Objects for the local copy of zlib. The variable ZLIB is set to
215-
# $(ZLIBOBJ) if the internal version of zlib should be used.
216-
ZLIBOBJ = \
217-
zlib/adler32.$(O) \
218-
zlib/crc32.$(O) \
219-
zlib/infback.$(O) \
220-
zlib/inffast.$(O) \
221-
zlib/inflate.$(O) \
222-
zlib/inftrees.$(O) \
223-
zlib/zutil.$(O)
224-
225-
LIBOBJ = $(LIBOBJ_W) $(LIBOBJ_NW) $(ZLIB)
226-
ALLOBJ_W = $(NASM) $(LIBOBJ_W)
227-
ALLOBJ = $(PROGOBJ) $(LIBOBJ) $(LIBOBJ_DIS)
222+
LIBOBJ = $(LIBOBJ_COM) $(LIBOBJ_ASM) $(LIBOBJ_DIS)
223+
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
228224
SUBDIRS = stdlib nasmlib include config output asm disasm x86 \
229225
common zlib macros misc
230226
XSUBDIRS = nsis win test doc editors
@@ -241,21 +237,27 @@ $(DIRS):
241237
@$(MKDIR_P) $(SUBDIRS) $(XSUBDIRS)
242238

243239
NASMLIB = libnasm.$(A)
244-
DISLIB = libndis.$(A)
240+
ASMLIB = libasm.$(A)
241+
DISLIB = libdis.$(A)
245242

246-
$(NASMLIB): $(LIBOBJ)
243+
$(NASMLIB): $(LIBOBJ_COM)
247244
$(RM_F) $(NASMLIB)
248-
$(AR) cq $(NASMLIB) $(LIBOBJ)
245+
$(AR) cq $(NASMLIB) $(LIBOBJ_COM)
249246
$(RANLIB) $(NASMLIB)
250247

248+
$(ASMLIB): $(LIBOBJ_ASM)
249+
$(RM_F) $(ASMLIB)
250+
$(AR) cq $(ASMLIB) $(LIBOBJ_ASM)
251+
$(RANLIB) $(ASMLIB)
252+
251253
$(DISLIB): $(LIBOBJ_DIS)
252254
$(RM_F) $(DISLIB)
253255
$(AR) cq $(DISLIB) $(LIBOBJ_DIS)
254256
$(RANLIB) $(DISLIB)
255257

256-
nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
258+
nasm$(X): $(NASM) $(MANIFEST) $(ASMLIB) $(NASMLIB)
257259
$(CC) $(ALL_LDFLAGS) -o $@ $(NASM) $(MANIFEST) \
258-
$(NASMLIB) $(LIBS)
260+
$(ASMLIB) $(NASMLIB) $(LIBS)
259261

260262
ndisasm$(X): $(NDISASM) $(MANIFEST) $(DISLIB) $(NASMLIB)
261263
$(CC) $(ALL_LDFLAGS) -o $@ $(NDISASM) $(MANIFEST) \

Mkfiles/msvc.mak

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,45 @@ NDISASM = disasm\ndisasm.obj
8686
PROGOBJ = $(NASM) $(NDISASM)
8787
PROGS = nasm$(X) ndisasm$(X)
8888

89+
# Objects for the local copy of zlib. The variable ZLIB is set to
90+
# $(ZLIBOBJ) if the internal version of zlib should be used.
91+
ZLIBOBJ = \
92+
zlib\adler32.obj \
93+
zlib\crc32.obj \
94+
zlib\infback.obj \
95+
zlib\inffast.obj \
96+
zlib\inflate.obj \
97+
zlib\inftrees.obj \
98+
zlib\zutil.obj
99+
100+
# Common library objects
101+
LIBOBJ_COM = \
102+
stdlib\snprintf.obj stdlib\vsnprintf.obj stdlib\strlcpy.obj \
103+
stdlib\strnlen.obj stdlib\strrchrnul.obj \
104+
\
105+
nasmlib\ver.obj \
106+
nasmlib\alloc.obj nasmlib\asprintf.obj \
107+
nasmlib\crc32b.obj nasmlib\crc64.obj nasmlib\md5c.obj \
108+
nasmlib\string.obj nasmlib\nctype.obj \
109+
nasmlib\file.obj nasmlib\mmap.obj nasmlib\ilog2.obj \
110+
nasmlib\realpath.obj nasmlib\path.obj \
111+
nasmlib\filename.obj nasmlib\rlimit.obj \
112+
nasmlib\numstr.obj \
113+
nasmlib\zerobuf.obj nasmlib\bsi.obj \
114+
nasmlib\rbtree.obj nasmlib\hashtbl.obj \
115+
nasmlib\raa.obj nasmlib\saa.obj \
116+
nasmlib\strlist.obj \
117+
nasmlib\perfhash.obj nasmlib\badenum.obj \
118+
nasmlib\readnum.obj \
119+
\
120+
common\common.obj common\errstubs.obj \
121+
\
122+
x86\insnsa.obj x86\insnsb.obj x86\insnsn.obj \
123+
x86\regs.obj x86\regvals.obj x86\regflags.obj \
124+
x86\iflag.obj \
125+
\
126+
$(ZLIB)
127+
89128
# Files dependent on warnings.dat
90129
WARNOBJ = asm\warnings.obj
91130
WARNFILES = asm\warnings_c.h include\warnings.h doc\warnings.src
@@ -99,10 +138,8 @@ OUTPUTOBJ = \
99138
output\outdbg.obj output\outieee.obj output\outmacho.obj \
100139
output\codeview.obj
101140

102-
# The source files for these objects are scanned for warnings
103-
LIBOBJ_W = \
104-
nasmlib\readnum.obj \
105-
\
141+
# Assembler-only library objects
142+
LIBOBJ_ASM = \
106143
asm\error.obj \
107144
asm\floats.obj \
108145
asm\directiv.obj \
@@ -116,66 +153,25 @@ LIBOBJ_W = \
116153
asm\segalloc.obj \
117154
asm\rdstrnum.obj \
118155
asm\srcfile.obj \
119-
\
120-
$(OUTPUTOBJ)
121-
122-
# The source files for these objects are NOT scanned for warnings;
123-
# normally this will include all generated files.
124-
# It is entirely possible that it may be necessary to move some of these
125-
# files to LIBOBJ_W, notably $(OUTPUTOBJ)
126-
LIBOBJ_NW = \
127-
stdlib\snprintf.obj stdlib\vsnprintf.obj stdlib\strlcpy.obj \
128-
stdlib\strnlen.obj stdlib\strrchrnul.obj \
129-
\
130156
asm\directbl.obj \
131157
asm\pptok.obj \
132158
asm\tokhash.obj \
133159
asm\uncompress.obj \
134160
\
135161
macros\macros.obj \
136162
\
137-
nasmlib\ver.obj \
138-
nasmlib\alloc.obj nasmlib\asprintf.obj \
139-
nasmlib\crc32b.obj nasmlib\crc64.obj nasmlib\md5c.obj \
140-
nasmlib\string.obj nasmlib\nctype.obj \
141-
nasmlib\file.obj nasmlib\mmap.obj nasmlib\ilog2.obj \
142-
nasmlib\realpath.obj nasmlib\path.obj \
143-
nasmlib\filename.obj nasmlib\rlimit.obj \
144-
nasmlib\numstr.obj \
145-
nasmlib\zerobuf.obj nasmlib\bsi.obj \
146-
nasmlib\rbtree.obj nasmlib\hashtbl.obj \
147-
nasmlib\raa.obj nasmlib\saa.obj \
148-
nasmlib\strlist.obj \
149-
nasmlib\perfhash.obj nasmlib\badenum.obj \
150-
\
151-
common\common.obj \
152-
\
153-
x86\insnsa.obj x86\insnsb.obj x86\insnsn.obj \
154-
x86\regs.obj x86\regvals.obj x86\regflags.obj \
155-
x86\iflag.obj \
156-
\
157-
$(WARNOBJ)
163+
$(WARNOBJ) \
164+
$(OUTPUTOBJ)
158165

159166
# Objects which are only used for the disassembler
160167
LIBOBJ_DIS = \
161168
disasm\disasm.obj disasm\sync.obj disasm\prefix.obj \
169+
disasm\diserror.obj \
162170
\
163171
x86\insnsd.obj x86\regdis.obj
164172

165-
# Objects for the local copy of zlib. The variable ZLIB is set to
166-
# $(ZLIBOBJ) if the internal version of zlib should be used.
167-
ZLIBOBJ = \
168-
zlib\adler32.obj \
169-
zlib\crc32.obj \
170-
zlib\infback.obj \
171-
zlib\inffast.obj \
172-
zlib\inflate.obj \
173-
zlib\inftrees.obj \
174-
zlib\zutil.obj
175-
176-
LIBOBJ = $(LIBOBJ_W) $(LIBOBJ_NW) $(ZLIB)
177-
ALLOBJ_W = $(NASM) $(LIBOBJ_W)
178-
ALLOBJ = $(PROGOBJ) $(LIBOBJ) $(LIBOBJ_DIS)
173+
LIBOBJ = $(LIBOBJ_COM) $(LIBOBJ_ASM) $(LIBOBJ_DIS)
174+
ALLOBJ = $(PROGOBJ) $(LIBOBJ)
179175
SUBDIRS = stdlib nasmlib include config output asm disasm x86 \
180176
common zlib macros misc
181177
XSUBDIRS = nsis win test doc editors
@@ -186,22 +182,26 @@ EDITORS = editors\nasmtok.el editors\nasmtok.json
186182
#-- End File Lists --#
187183

188184
NASMLIB = libnasm.$(A)
189-
NDISLIB = libndis.$(A)
185+
ASMLIB = libasm.$(A)
186+
DISLIB = libdis.$(A)
190187

191188
all: nasm$(X) ndisasm$(X)
192189

193-
nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB)
194-
$(CC) /Fe:$@ $(ALL_CFLAGS) $(NASM) $(NASMLIB) $(LIBS) \
190+
nasm$(X): $(NASM) $(MANIFEST) $(ASMLIB) $(NASMLIB)
191+
$(CC) /Fe:$@ $(ALL_CFLAGS) $(NASM) $(ASMLIB) $(NASMLIB) $(LIBS) \
195192
$(ALL_LDFLAGS)
196193

197-
ndisasm$(X): $(NDISASM) $(MANIFEST) $(NDISLIB) $(NASMLIB)
198-
$(CC) /Fe:$@ $(ALL_CFLAGS) $(NDISASM) $(NDISLIB) $(NASMLIB) $(LIBS) \
194+
ndisasm$(X): $(NDISASM) $(MANIFEST) $(DISLIB) $(NASMLIB)
195+
$(CC) /Fe:$@ $(ALL_CFLAGS) $(NDISASM) $(DISLIB) $(NASMLIB) $(LIBS) \
199196
$(ALL_LDFLAGS)
200197

201-
$(NASMLIB): $(LIBOBJ)
198+
$(NASMLIB): $(LIBOBJ_COM)
199+
$(AR) $(ARFLAGS) /out:$@ $**
200+
201+
$(ASMLIB): $(LIBOBJ_ASM)
202202
$(AR) $(ARFLAGS) /out:$@ $**
203203

204-
$(NDISLIB): $(LIBOBJ_DIS)
204+
$(DISLIB): $(LIBOBJ_DIS)
205205
$(AR) $(ARFLAGS) /out:$@ $**
206206

207207
# These are specific to certain Makefile syntaxes...

0 commit comments

Comments
 (0)