Commit 4389c2e0 authored by PoroCYon's avatar PoroCYon Committed by PoroCYon
Browse files

add more detailed exported symbols, useful for compressed code size listings

parent e0bde71b
......@@ -6,6 +6,8 @@
%include "elf.inc"
global _EHDR
_EHDR:
ehdr:
; e_ident
db 0x7F, "ELF"
......@@ -47,6 +49,8 @@ ehdr:
; dd (PHDR_R | PHDR_W)
; dd 0x1;000
%else
global _PHDR
_PHDR:
phdr:
%endif
%ifdef USE_INTERP
......@@ -81,6 +85,8 @@ phdr.end:
%ifdef USE_INTERP
[section .rodata.interp]
global _INTERP
_INTERP:
interp:
db "/lib/ld-linux.so.2",0
interp.end:
......
......@@ -6,6 +6,8 @@
%include "elf.inc"
global _EHDR
_EHDR:
ehdr:
; e_ident
db 0x7F, "ELF"
......@@ -32,6 +34,8 @@ ehdr:
ehdr.end:
%endif
global _PHDR
_PHDR:
phdr:
%ifdef USE_INTERP
phdr.interp:
......@@ -88,6 +92,8 @@ phdr.end:
%ifdef USE_INTERP
[section .rodata.interp]
global _INTERP
_INTERP:
interp:
db "/lib64/ld-linux-x86-64.so.2", 0
interp.end:
......
......@@ -12,12 +12,15 @@
%endif
%ifndef USE_DNLOAD_LOADER
global _smol_priv_data
_smol_priv_data:
_smol_linkmap:
dd 0
_smol_linkoff:
dd 0
%endif
global _smol_start
_smol_start:
mov eax, [esp - 32] ; ???
......@@ -273,4 +276,8 @@ repne scasd
;jmp short _start
; by abusing the linker script, _start ends up right here :)
%ifdef ELF_TYPE
global _smol_rt_end:
_smol_rt_end:
%endif
......@@ -23,6 +23,7 @@ extern _symbols
global _start
_start:
%endif
global _smol_start:
_smol_start:
%ifdef USE_DL_FINI
xchg r13, rdx ; _dl_fini
......@@ -250,5 +251,9 @@ repne scasd ; technically, scasq should be used, but meh. this is 1 byte smaller
xchg rsi, r13 ; _dl_fini
%endif
; fallthru to _start
%ifdef ELF_TYPE
global _smol_rt_end:
_smol_rt_end:
%endif
;.loopme: jmp short .loopme
......@@ -60,6 +60,7 @@ dynamic.end:
""")
outf.write('[section .rodata.neededlibs]\n')
outf.write('global _strtab\n')
outf.write('_strtab:\n')
for library, symrels in libraries.items():
outf.write('\t_symbols.{}: db "{}",0\n'.format(shorts[library], library))
......@@ -68,6 +69,7 @@ dynamic.end:
if not nx:
outf.write('[section .text.smolplt]\n')
outf.write('global _symbols\n')
outf.write('_symbols:\n')
for library, symrels in libraries.items():
for sym, reloc in symrels:
......@@ -90,6 +92,7 @@ dynamic.end:
outf.write('_symbols.end:\n')
if nx:
outf.write('global _smolplt\n')
outf.write('_smolplt:\n')
for library, symrels in libraries.items():
for sym, reloc in symrels:
......@@ -139,12 +142,14 @@ dynamic.end:
outf.write('[section .rodata.neededlibs]\n')
outf.write('global _strtab\n')
outf.write('_strtab:\n')
for library, symrels in libraries.items():
outf.write('\t_symbols.{}: db "{}",0\n'.format(shorts[library], library))
outf.write('[section .data.smolgot]\n')
outf.write('global _symbols\n')
outf.write('_symbols:\n')
for library, symrels in libraries.items():
for sym, reloc in symrels:
......@@ -166,6 +171,7 @@ global {name}
outf.write('db 0\n')
outf.write('_symbols.end:\n')
outf.write('global _smolplt\n')
outf.write('_smolplt:\n')
for library, symrels in libraries.items():
for sym, reloc in symrels:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment