This is the mail archive of the 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]

Differentiate b/w dynamic and static executables.

Hi All,

We have a situation, where we defined the program segments like in the
linker script

  headers PT_PHDR PHDRS ;
  interp PT_INTERP ;
  data PT_LOAD ;
  tls PT_TLS ;
  dynamic PT_DYNAMIC ;
  note PT_NOTE ;
  stack PT_GNU_STACK FLAGS(6);

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

Elf file type is EXEC (Executable file)
Entry point 0x2000037f1
There are 8 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz
 MemSiz   Flg Align
  PHDR           0x000040 0x0000000200000040 0x0000000200000040 0x0001c0
0x0001c0 R   0x8
  INTERP         0x000200 0x0000000200000200 0x0000000200000200 0x00000f
0x00000f R   0x1
      [Requesting program interpreter: /lib/]
  LOAD           0x000000 0x0000000200000000 0x0000000200000000 0x011100
0x011100 R E 0x1000
  LOAD           0x011fd0 0x0000000200013fd0 0x0000000200013fd0 0x000330
0x000898 RW  0x1000
  TLS            0x000000 0x0000000000000000 0x0000000000000000 0x000000
0x000000     0x8
  DYNAMIC        0x000000 0x0000000000000000 0x0000000000000000 0x000000
0x000000     0x8
readelf: Warning: the .dynamic section is not contained within the dynamic
  NOTE           0x000000 0x0000000000000000 0x0000000000000000 0x000000
0x000000     0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000
0x000000 RW  0x8

Version used :

GNU ld (GNU Binutils) 2.33.1
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later
This program has absolutely no warranty.

$file final.exe
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked,
interpreter *empty*, not stripped

the same script used both static and dynamic executables, one solution
would be like have two scripts with PT_DYNAMIC and without.

But any inputs or suggestions, how we can use the unified script for both
static and dynamic executables?

Thank you

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