09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>XENIX</strong> Programming cc: C Compiler<br />

Using Modules, Segments, and Groups<br />

"Module" is another name for an object file created by the C compiler. Every module<br />

has a name, and the cc command uses this name in error messages if problems are<br />

encountered during linking. The module name is usually the same as the source file's<br />

name (without the ".c" or ".s" extension). You can change this name using the -NM<br />

option. The option has the form<br />

-NM name<br />

where name can be any combination of letters and digits.<br />

Changing a module's name is useful if the source file to be compiled is actually the<br />

output of a program preprocessor and generator, such as lex or yacc.<br />

A "segment" is a contiguous block of binary code produced by the C compiler. Every<br />

module has two segments: a text segment containing the program instructions, and a<br />

data segment containing the program data. Each segment in every module has a name.<br />

This name is used by cc to define the order in which the segments of the program will<br />

appear in memory when loaded for execution. Text segments having the same name are<br />

loaded as a contiguous block of code. Data segments of the same name are also loaded<br />

as contiguous blocks.<br />

Text and data segment names are normally created by the C compiler. These default<br />

names depend on the memory model chosen for the program. For example, in small<br />

model programs the text segment is named " TEXT" and the data segment is named<br />

"_DATA". These names are the same for all small model modules, so all segments from<br />

all modules of a small model program are loaded as a contiguous block. In middle model<br />

programs, each text segment has a different name. In large and huge model programs,<br />

each text and data segment has a different name. The default text and data segment<br />

names for middle, large, and huge model programs are given in the section "Segment and<br />

Module Names" at the end of this chapter.<br />

You can override the default names used by the C compiler (and override the default<br />

loading order) by using the -NT and -ND options. These options set the names of the<br />

text and data segments, in each module being compiled, to a given name. The options<br />

have the form<br />

and<br />

-NT name<br />

-ND name<br />

where name is any combination of letters and digits. These options are useful in middle,<br />

large, and huge model programs where there is no specific loading order. In these<br />

programs, you can guarantee contiguous loading for two or more segments by giving<br />

them the same name.<br />

Note: Modules compiled with -ND option cannot call any system libraries.<br />

2-19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!