Hi,
when I tried to switch to new nasm for one of our projects,
nasm started panicking;
nasm: panic: rdf segment numbers not allocated as expected (0,0,0)
nasm code in question calls seg_alloc 3 times:
segtext = seg_alloc();
segdata = seg_alloc();
segbss = seg_alloc();
if (segtext != 0 || segdata != 2 || segbss != 4)
nasm_panic(0,
"rdf segment numbers not allocated as expected (%d,%d,%d)",
segtext, segdata, segbss);
and seg_alloc returns consecutive even integers, so it should never
happen that all three would be zeroes.
Except that seg_alloc() is marked as pure_func, and so new gcc figures
out that seg_alloc() returns constant, and so it can call it just once,
and then assign returned value to all three variables :-(
Simple fix below solves the problem.
Petr
Signed-off-by: Petr Vandrovec <petr@vandrovec.name>
--- nasm-2.13.03/include/nasmlib.h 2018-02-07 13:40:15.000000000 -0800
+++ nasm-2.13.03.patched/include/nasmlib.h 2018-07-06 22:59:37.595561715 -0700
@@ -192,7 +192,7 @@
* seg_alloc: allocate a hitherto unused segment number.
*/
void pure_func seg_init(void);
-int32_t pure_func seg_alloc(void);
+int32_t seg_alloc(void);
/*
* many output formats will be able to make use of this: a standard