Forum > FPC development

.section .text

(1/1)

Key-Real:
finally I got fpc to compile me an assembly output.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---.section .text.n_main,"ax" .globl  main.type   main,@functionmain:  .globl PASCALMAIN .type  PASCALMAIN,@function PASCALMAIN:.ent main    ... code ... .end main.size   main, . - main 
so question
1) what is    .n_main,"ax"   ?
and
2) as i understand we start at main, so we have .ent and .end and .size debugger directives
    I thought fpc starts at PASCALMAIN? how to understand this?

Kays:
First of all, assembly highlighting is possible [code=asm][/code]. Secondly, the GNU Assembler has a manual explaining everything. To summarize: Normally, everything belonging to one section is gathered in textual order. The subsection extension allows mixing various texts, thus

--- Code: ASM  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---.section .text.fooABC.section .text.barCDE.section .text.fooFGHbecomes

--- Code: ASM  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---.section .text; now all `foo` textsABCFGH; now all `bar` textsCDEeven though ABC/FGH was “interrupted” by CDE. This allows more readable source code. The string "ax" merely indicates the custom section is allocated and executable. I’m not sure about your other question, so I’ll leave it for someone else to answer.

Key-Real:
ah, ok,
my question was wrong formulated.

I need to knew why this section is called n_main?
Is it a requerment for something?

Kays:

--- Quote from: Key-Real on April 26, 2024, 02:05:45 pm ---[…] I need to knew why this section is called n_main? […]
--- End quote ---
Because m_main was already taken. :D It’s really just a name and using a pattern – something, underscore, something – ensures there are no unwanted collisions. Based on
--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---strings ./myExecutableProgram | grep n_mainthe subsection name does not end up in the final executable.

nickysn:
On targets that support section based smartlinking (marked by the 'tf_smartlink_sections' flag in compiler/systems/i_*.pas), FPC puts each function in a separate section, i.e. something like that: '.text.n_NAMEOFFUNCTION'.

When linking the '--gc-sections' option is used, which causes the linker to remove ("garbage collect") unused sections and thus produce a smaller executable.

If the whole unit or program's code was put in a single section, called '.text', then unused functions won't be removed by the linker.

Navigation

[0] Message Index

Go to full version