This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Differentiate b/w dynamic and static executables.


Hi,

On 26.12.19 14:46, Umesh Kalappa wrote:

> for the static executable, where we don't need PT_DYNAMIC segment, but
> still  the final executable has the program segments like

The static executable also doesn't need a PT_INTERP segment, in fact it
shouldn't have one.

It might in theory be possible to build a unified linker script, but I'd
expect separate scripts to be more maintainable. If you do something
interesting in a script like collect fragments into lists (like C++
global initializers) then it is usually better to make a preliminary
link with a linker script that resolves the common parts and generates
another relocatable output, and then a final link that maps the sections
to segments.

Note that the standard C and C++ libraries are very much dependent on
their startup code, and that startup code defines a set of sections that
need to be linked in a particular way to work, so at the very least your
scripts also need to know about the requirements of the C/C++ libraries
you use.

The linker scripts shipped with the compiler are generated with a
preprocessor from a common source, but separate scripts are generated
for different cases (static/dynamic/shared/... debug/nodebug ...), so it
is likely not possible in a sensible way.

   Simon

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]