Recent

Author Topic: FreeBSD 13.1 cprt0.o error  (Read 3141 times)

d.ioannidis

  • Full Member
  • ***
  • Posts: 221
    • Nephelae
FreeBSD 13.1 cprt0.o error
« on: January 17, 2023, 02:47:06 pm »
Hi,

  I can't build / compile any project for FreeBSD box 13.1-RELEASE-p3(64-bit).

The error I'm getting is :

Code: Pascal  [Select][+][-]
  1. cprt0.o: .note.GNU-stack section implies executable stack

( see attached img )

Free Pascal ( 3.2.2 ) / Lazarus ( 2.2.4 ) installed using pkg.

Any hint ?

regards,

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: FreeBSD 13.1 cprt0.o error
« Reply #1 on: January 17, 2023, 04:02:13 pm »
Hello d.ioannidis.

Did you try to run applications compiled with FreeBSD 11 on your FreeBSD 13 machine?

For example, does this application run on your system? (just unzip and run "StrumPract" ) : https://github.com/fredvs/strumpract/releases/download/3.4.0/StrumPract_3_4_0_freebsd_amd64.zip

It was compiled with fpc 3.2.2. for FreeBSD 64 on a FreeBSD 11 system.

Thanks.

Fre;D

I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

sketch

  • New Member
  • *
  • Posts: 32
Re: FreeBSD 13.1 cprt0.o error
« Reply #2 on: January 17, 2023, 04:56:07 pm »
FreeBSD uses ld.lld which is as drop-in replacement for GNU binutils BFD and gold linkers. But your error message shows ld.BFD which seems like it is using GNU binutils. I don't know why the FreeBSD linker would report BFD just because it's a drop-in replacement. And since it is in /usr/local/bin makes it seem it is using GNU binutils. Otherwise, it would be in /usr/bin.

Anyway, the release of GNU binutils 2.39 added several new warnings to the linker.
Quote
Since binutils 2.39, ld will print a warning if any stack section is
executable, which is the default for stack sections on files without a
.note.GNU-stack section.
The warning
Quote
warning: cprt0.o: missing .note.GNU-stack section implies executable stack
is letting you know the program is being given an executable stack. Warning messages about the creation of an executable stack can be disabled with --no-warn-execstack and warnings about executable segments can be disabled --no-warn-rwx-segments.

Also check if you are using the GNU linker or the FreeBSD linker.
« Last Edit: January 17, 2023, 05:09:53 pm by sketch »

d.ioannidis

  • Full Member
  • ***
  • Posts: 221
    • Nephelae
Re: FreeBSD 13.1 cprt0.o error
« Reply #3 on: January 17, 2023, 07:27:40 pm »
Hi,

  @sketch
  @Fred vS

   apologies for my wrong post. I'm not familiar with BSD's.

  Actually, I can build and run programs just fine . I was misled by the log message while linking  which started with "Error:" and the fact that I was testing FreeBSD and FPC in a slow VM ...

  Sorry again for the noise ...

regards,

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: FreeBSD 13.1 cprt0.o error
« Reply #4 on: January 17, 2023, 08:11:11 pm »
Hi,

  @sketch
  @Fred vS

   apologies for my wrong post. I'm not familiar with BSD's.

  Actually, I can build and run programs just fine . I was misled by the log message while linking  which started with "Error:" and the fact that I was testing FreeBSD and FPC in a slow VM ...

  Sorry again for the noise ...

regards,

Ha, nice you make it work.
Also me sorry for the noise, I just tried the application compiled on FreeBSD 11 and fpc 3.2.2 on a FreeBSD 13 machine and it works out-of-the-box.

By the way, if you are new to FreeBSD, you may consider to try GhostBSD, it has all needed for a nice desktop machine and install is very easy:
https://ghostbsd.org/download
But maybe you want use FreeBSD only for console apps like server, if so, also sorry for that noise.
« Last Edit: January 17, 2023, 08:31:26 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: FreeBSD 13.1 cprt0.o error
« Reply #5 on: January 17, 2023, 08:47:56 pm »
I reworked some FreeBSD support in post 3.2.2 fixes and trunk. BSDers are recommended to upgrade asap.

To bootstrap, you need to make "ld.bfd" default (symlink to "ld"), and then bootstrap. After the bootstrap, the compiler will execute "ld.bfd" rather than "ld".

llvm ld is not workable at this moment, it seems to have no error handling, and simply silently omit everything it doesn't understand.

p.s. bootstrap experience might vary depending if you installed "COMPAT"systems while installing Freebsd or not.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: FreeBSD 13.1 cprt0.o error
« Reply #6 on: January 17, 2023, 09:19:50 pm »
I reworked some FreeBSD support in post 3.2.2 fixes and trunk. BSDers are recommended to upgrade asap.

To bootstrap, you need to make "ld.bfd" default (symlink to "ld"), and then bootstrap. After the bootstrap, the compiler will execute "ld.bfd" rather than "ld".

llvm ld is not workable at this moment, it seems to have no error handling, and simply silently omit everything it doesn't understand.

p.s. bootstrap experience might vary depending if you installed "COMPAT"systems while installing Freebsd or not.

Ha, nice, thanks, I will try.
To make fpc 3.2.2. work on my FreeBSD machine I had to change in /compiler/systems/t_bsd.pas, procedure TLinkerBSD.SetDefaultInfo :

Code: Pascal  [Select][+][-]
  1.  if (target_info.system in (systems_openbsd+[system_x86_64_dragonfly]))
  2.   or  (target_info.system in (systems_freebsd+[system_x86_64_freebsd]))  // add this
  3.   then LdProgram:='ld.bfd';

And recompile fpc and then all was ok.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: FreeBSD 13.1 cprt0.o error
« Reply #7 on: January 18, 2023, 04:22:30 pm »
Check you generated a real FreeBSD 13 binary (either file or elfdump -n).

This is what the post 3.2.2 fixes aim to solve, creating Free BSD 12/13 native binaries. (depending on the ELF identifier in rtl/freebsd/cprt0 etc)

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: FreeBSD 13.1 cprt0.o error
« Reply #8 on: January 18, 2023, 11:45:07 pm »
Check you generated a real FreeBSD 13 binary (either file or elfdump -n).

This is what the post 3.2.2 fixes aim to solve, creating Free BSD 12/13 native binaries. (depending on the ELF identifier in rtl/freebsd/cprt0 etc)

Hello Marco.

Doing this of a binary file compiled with fpc official release 3.2.2 + my patch on a FreeBSD 13.1 system (last GhostBSD):

Code: Bash  [Select][+][-]
  1. $ file strumpract

gives this:

Quote
strumpract: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /usr/libexec/ld-elf.so.1, stripped

elfdump -n strumpract gives nothing.

How can I see if it was a real FreeBSD 13 binary?
« Last Edit: January 18, 2023, 11:53:22 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: FreeBSD 13.1 cprt0.o error
« Reply #9 on: January 19, 2023, 09:25:00 am »
Probably the elfdump failure is a sign. -n dumps note sections, and the note sections changed in newer FreeBSD.

So that is probably an older -compat binary.

pelle

  • Newbie
  • Posts: 2
Re: FreeBSD 13.1 cprt0.o error
« Reply #10 on: October 24, 2023, 07:38:20 pm »
Being a bit new both to FreePascal and FreeBSD I am not sure what to do about this.

The message I see (in FreeBSD 13.2) is only a warning, not an error,  and it seems as if the generated binary runs properly, at least for very simple test-programs.

But it is annoying to get a warning every time, and it looks like it may turn into an error on future upgrade?

Code: [Select]
/usr/local/bin/ld.bfd: warning: /usr/local/lib/fpc/3.2.2/units/x86_64-freebsd/rtl/prt0.o: missing .note.GNU-stack section implies executable stack
/usr/local/bin/ld.bfd: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Should this perhaps be reported to someone that is building the official FreeBSD package? Is the only way for now to patch the fpc code and recompile it?

What makes me a bit confused is that it seems like I already have ld.bfd, and that is the linker that should be used, right?

AlexTP

  • Hero Member
  • *****
  • Posts: 2383
    • UVviewsoft
Re: FreeBSD 13.1 cprt0.o error
« Reply #11 on: October 24, 2023, 08:37:27 pm »
What you can do: don't use BSD packaged FPC/Lazarus, but get fpcUpDeluxe and install the last git version (or last release version?)

pelle

  • Newbie
  • Posts: 2
Re: FreeBSD 13.1 cprt0.o error
« Reply #12 on: October 28, 2023, 11:45:58 pm »
What you can do: don't use BSD packaged FPC/Lazarus, but get fpcUpDeluxe and install the last git version (or last release version?)

OK. Thanks for the suggestion. Unfortunately I tried now with both with the trunk and stable versions, but I get the same linker warning with both (same as for the packaged version).

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: FreeBSD 13.1 cprt0.o error
« Reply #13 on: February 20, 2024, 03:52:00 pm »

cprt, dllprt and gprt now have non-xecutable stack note in trunk and fixes that silences the warning.

Note that this only came out when you linked dynamically linked binaries.


 

TinyPortal © 2005-2018