From: nasm-bot f. H. P. A. <hp...@li...> - 2016-02-17 01:57:38
|
Commit-ID: 2c4a4d5810d0a59b033a07876a2648ef5d4c2859 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=2c4a4d5810d0a59b033a07876a2648ef5d4c2859 Author: H. Peter Anvin <hp...@li...> AuthorDate: Tue, 16 Feb 2016 17:37:18 -0800 Committer: H. Peter Anvin <hp...@li...> CommitDate: Tue, 16 Feb 2016 17:37:18 -0800 Simplify handling of segments and segalign Slightly simplify the handling of segment number allocation. If we are in absolute space, never push a segalign down to the backend. Signed-off-by: H. Peter Anvin <hp...@li...> --- nasm.c | 6 +++--- nasmlib.c | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/nasm.c b/nasm.c index 55c7a2a..a176f25 100644 --- a/nasm.c +++ b/nasm.c @@ -343,8 +343,6 @@ int main(int argc, char **argv) preproc = &nasmpp; operating_mode = OP_NORMAL; - seg_init(); - /* Define some macros dependent on the runtime, but not on the command line. */ define_macros_early(); @@ -1291,8 +1289,10 @@ static void assemble_file(char *fname, StrList **depend_ptr) "segment alignment `%s' is not power of two", value); } + /* callee should be able to handle all details */ - ofmt->sectalign(location.segment, align); + if (location.segment != NO_SEG) + ofmt->sectalign(location.segment, align); } } break; diff --git a/nasmlib.c b/nasmlib.c index 656350d..cf39468 100644 --- a/nasmlib.c +++ b/nasmlib.c @@ -391,16 +391,14 @@ int64_t readstrnum(char *str, int length, bool *warn) return charconst; } -static int32_t next_seg; - -void seg_init(void) -{ - next_seg = 0; -} - int32_t seg_alloc(void) { - return (next_seg += 2) - 2; + static int32_t next_seg = 0; + int32_t this_seg = next_seg; + + next_seg += 2; + + return this_seg; } #ifdef WORDS_LITTLEENDIAN |