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