03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

To be executed, an executable has to be loaded. This means that its program and data<br />

areas must be prepared for use. There are two cases here:<br />

� The first case is an executable in ROM (drive z:). ROM-based executables are<br />

executed in-place.<br />

� Executables not in ROM must first be loaded into RAM. This applies to executables on<br />

memory cards (removable media drive d:), or in the system Flash, or RAM, disk (drive<br />

c:).<br />

2.4.2 Loading and Sharing<br />

Executables may contain three types of binary data:<br />

� program code<br />

� read-only static data<br />

� read/write static data.<br />

When a .exe is first loaded into RAM, it has its own areas for code, read-only data and<br />

read/write data. If a second version of the same .exe is launched, the code and static data<br />

are shared, and a new area will be allocated only for the read/write data. Even on first use,<br />

ROM-based<br />

.exes allocate a RAM area only for read/write data – the program code and read-only data<br />

are read directly from ROM.<br />

As is explained later in this chapter, Symbian OS DLLs contain no read/write data and so do<br />

not need to allocate RAM to hold it. When a DLL is first loaded into RAM, it is relocated to a<br />

particular address. If a second thread requires the same DLL, it doesn't have to load it – it<br />

merely attaches the copy already there. The DLL appears at the same address in all threads<br />

that use it. ROM-based DLLs are not actually loaded at all – they are simply used in-place in<br />

ROM.<br />

Symbian OS maintains reference counts so that a RAM-based DLL or.exe is only discarded<br />

when the count drops to zero.<br />

2.4.3 Cutting Down the Size<br />

Symbian OS optimizes the formats used for DLLs in order to make them as compact as<br />

possible in ROM and RAM.<br />

� Most systems supporting DLLs or analogous concepts offer two options for identifying<br />

the entry points in them. You can refer to the entry points either by name or by ordinal<br />

number. Names are potentially long and wasteful of ROM and RAM. So Symbian OS<br />

uses link-by-ordinal exclusively.<br />

� Loading into RAM can involve locating the executable at an address that cannot be<br />

determined until load time: this means that relocation information has to be included in<br />

the executable format. Loading into ROM happens effectively at build time. So Symbian<br />

OS ROM- building tools perform the relocation and strip the DLLs of their relocation<br />

information to make them still smaller.<br />

The Symbian OS link-by-ordinal scheme affects the disciplines used for binary compatibility<br />

(a future release of a DLL must use exactly the same ordinals as the previous release). The<br />

preloading scheme means, among other things, that you can't take an executable out of the<br />

ROM and deliver it in another package for RAM loading. These are largely matters for<br />

Symbian OS OEMs and I shan't be describing them further in this book.<br />

2.4.4 Launching Applications and Servers

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

Saved successfully!

Ooh no, something went wrong!