Commit d39c229e authored by Geza Lore's avatar Geza Lore Committed by Henrik Gramner

x86inc: Add debug symbols indicating sizes of compiled functions

Some debuggers/profilers use this metadata to determine which function a
given instruction is in; without it they get can confused by local labels
(if you haven't stripped those). On the other hand, some tools are still
confused even with this metadata. e.g. this fixes `gdb`, but not `perf`.

Currently only implemented for ELF.
parent d3662777
...@@ -48,7 +48,7 @@ cextern w7_min_w5 ...@@ -48,7 +48,7 @@ cextern w7_min_w5
%include "libavcodec/x86/simple_idct10_template.asm" %include "libavcodec/x86/simple_idct10_template.asm"
section .text align=16 SECTION .text
%macro idct_fn 0 %macro idct_fn 0
cglobal prores_idct_put_10, 4, 4, 15 cglobal prores_idct_put_10, 4, 4, 15
......
...@@ -65,7 +65,7 @@ CONST_DEC w7_min_w5, W7sh2, -W5sh2 ...@@ -65,7 +65,7 @@ CONST_DEC w7_min_w5, W7sh2, -W5sh2
%include "libavcodec/x86/simple_idct10_template.asm" %include "libavcodec/x86/simple_idct10_template.asm"
section .text align=16 SECTION .text
%macro idct_fn 0 %macro idct_fn 0
cglobal simple_idct10, 1, 1, 16 cglobal simple_idct10, 1, 1, 16
......
...@@ -634,6 +634,7 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14 ...@@ -634,6 +634,7 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14
%else %else
rep ret rep ret
%endif %endif
annotate_function_size
%endmacro %endmacro
%define last_branch_adr $$ %define last_branch_adr $$
...@@ -642,6 +643,7 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14 ...@@ -642,6 +643,7 @@ DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14
times ((last_branch_adr-$)>>31)+1 rep ; times 1 iff $ == last_branch_adr. times ((last_branch_adr-$)>>31)+1 rep ; times 1 iff $ == last_branch_adr.
%endif %endif
ret ret
annotate_function_size
%endmacro %endmacro
%macro BRANCH_INSTR 0-* %macro BRANCH_INSTR 0-*
...@@ -666,6 +668,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, ...@@ -666,6 +668,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae,
%elif %2 %elif %2
jmp %1 jmp %1
%endif %endif
annotate_function_size
%endmacro %endmacro
;============================================================================= ;=============================================================================
...@@ -687,6 +690,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, ...@@ -687,6 +690,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae,
cglobal_internal 0, %1 %+ SUFFIX, %2 cglobal_internal 0, %1 %+ SUFFIX, %2
%endmacro %endmacro
%macro cglobal_internal 2-3+ %macro cglobal_internal 2-3+
annotate_function_size
%if %1 %if %1
%xdefine %%FUNCTION_PREFIX private_prefix %xdefine %%FUNCTION_PREFIX private_prefix
%xdefine %%VISIBILITY hidden %xdefine %%VISIBILITY hidden
...@@ -700,6 +704,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, ...@@ -700,6 +704,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae,
CAT_XDEFINE cglobaled_, %2, 1 CAT_XDEFINE cglobaled_, %2, 1
%endif %endif
%xdefine current_function %2 %xdefine current_function %2
%xdefine current_function_section __SECT__
%if FORMAT_ELF %if FORMAT_ELF
global %2:function %%VISIBILITY global %2:function %%VISIBILITY
%else %else
...@@ -748,6 +753,24 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, ...@@ -748,6 +753,24 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae,
[SECTION .note.GNU-stack noalloc noexec nowrite progbits] [SECTION .note.GNU-stack noalloc noexec nowrite progbits]
%endif %endif
; Tell debuggers how large the function was.
; This may be invoked multiple times per function; we rely on later instances overriding earlier ones.
; This is invoked by RET and similar macros, and also cglobal does it for the previous function,
; but if the last function in a source file doesn't use any of the standard macros for its epilogue,
; then its size might be unspecified.
%macro annotate_function_size 0
%ifdef __YASM_VER__
%ifdef current_function
%if FORMAT_ELF
current_function_section
%%ecf equ $
size current_function %%ecf - current_function
__SECT__
%endif
%endif
%endif
%endmacro
; cpuflags ; cpuflags
%assign cpuflags_mmx (1<<0) %assign cpuflags_mmx (1<<0)
......
...@@ -66,14 +66,14 @@ cextern fail_func ...@@ -66,14 +66,14 @@ cextern fail_func
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
cglobal stack_clobber, 1,2 cglobal stack_clobber, 1,2
; Clobber the stack with junk below the stack pointer ; Clobber the stack with junk below the stack pointer
%define size (max_args+6)*8 %define argsize (max_args+6)*8
SUB rsp, size SUB rsp, argsize
mov r1, size-8 mov r1, argsize-8
.loop: .loop:
mov [rsp+r1], r0 mov [rsp+r1], r0
sub r1, 8 sub r1, 8
jge .loop jge .loop
ADD rsp, size ADD rsp, argsize
RET RET
%if WIN64 %if WIN64
......
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