Forum > Documentation (Maintaining -)

Wiki of hardening

(1/1)

Fred vS:
Hello.

In the wiki: https://wiki.freepascal.org/hardening

There is a example with result.
I did compile the demo using the parameters with fpc 3.3.1 (because 3.2.2 does not allow it).

But I dont get same result as wiki:

--- Quote ---program Test;
{$linklib c}
begin
  writeln('test');
end.

Compile with this -
fpc  -Cg  -k-pie  -k-znow  test.pas

And examine the result -

$> file test [enter]
test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.4.0, stripped
--- End quote ---

My result has LSB pie executable (that means, afaik, that the binary was hardened)


--- 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";}};} ---file testtest: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.4.0, stripped 
Also, there was no strip parameter used, so why file reports the binary as stripped ?

What do I miss ?

MarkMLl:

--- Quote from: Fred vS on May 15, 2023, 06:20:38 pm ---Also, there was no strip parameter used, so why file reports the binary as stripped ?

--- End quote ---

What happens if you explicitly specify that debugging information should be included?

MarkMLl

TRon:

--- Quote from: Fred vS on May 15, 2023, 06:20:38 pm ---Also, there was no strip parameter used, so why file reports the binary as stripped ?

What do I miss ?

--- End quote ---
As a guess: fpc.cfg ?

compile with -va to see what FPC picks up (if anything)

Fred vS:

--- Quote from: MarkMLl on May 16, 2023, 10:05:38 am ---
--- Quote from: Fred vS on May 15, 2023, 06:20:38 pm ---Also, there was no strip parameter used, so why file reports the binary as stripped ?

--- End quote ---

What happens if you explicitly specify that debugging information should be included?

MarkMLl

--- End quote ---

Hello Mark.

Well seen, indeed with "-ghl" parameter it is not stripped.


--- 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";}};} ---> file test test: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.4.0, with debug_info, not stripped 
So good to know that, by default, the binary is stripped.

Thanks.


--- Quote from: TRon on May 16, 2023, 10:05:38 am ---As a guess: fpc.cfg ?

--- End quote ---

Hello TRon.
No, nothing in fpc.cfg that could explain the "stripped".

[EDIT] Even without hardening and with fpc 3.2.2 or fpc 3.3.1. the binary is declared as stripped  (even compiled without any parameter, like fpc test ).

Fre;D

Navigation

[0] Message Index

Go to full version