Recent

Author Topic: build 32bit .so with -fPIC  (Read 2372 times)

abk.964

  • Newbie
  • Posts: 6
build 32bit .so with -fPIC
« on: December 28, 2024, 10:22:48 am »
Hi.
I try to build 32bit (i386) shared library with -fPIC option.
Create new project "Library", set target Linux i386, add -fPIC and -Cg to custom options (think it's synonym), pass to linker option --warn-shared-textrel.

Linker say:
Code: [Select]
/usr/bin/ld: //usr/lib/fpc/3.2.2/units/i386-linux/rtl/system.o: warning: relocation in read-only section `.text.n_system_$$_fpsigaction$longint$psigactionrec$psigactionrec$$longint'
/usr/bin/ld: warning: creating a DT_TEXTREL in a shared object

"readelf -d" say
Code: [Select]
0x00000016 (TEXTREL)                    0x0
0x0000001e (FLAGS)                      TEXTREL

I use Lazarus 3.99 64bit, FPC 3.2.2, Debian 10 64bit.
32bit FPC runtime builded from sources with default options.

I found Fpsigaction in ossysc.inc. Can`t understand, what a problem with it.

How to build 32bit .so without TEXTREL ?

abou.almontacir

  • New member
  • *
  • Posts: 8
Re: build 32bit .so with -fPIC
« Reply #1 on: February 02, 2025, 06:03:57 pm »
I'm also working on enabling PIC for Debian and have similar issue.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5938
  • Compiler Developer
Re: build 32bit .so with -fPIC
« Reply #2 on: February 02, 2025, 08:31:03 pm »
32bit FPC runtime builded from sources with default options.

Try to rebuild your 32-bit FPC distribution with OPT=-Cg just to be sure that everything is alright there.

abk.964

  • Newbie
  • Posts: 6
Re: build 32bit .so with -fPIC
« Reply #3 on: February 03, 2025, 08:16:57 am »
Use parameter CREATESHARED rebuilding runtime. For example:
Code: Bash  [Select][+][-]
  1. make all OS_TARGET=linux CPU_TARGET=i386 CREATESHARED=1
  2.  
It turns on -Cg option.
« Last Edit: February 03, 2025, 08:20:37 am by abk.964 »

dbannon

  • Hero Member
  • *****
  • Posts: 3308
    • tomboy-ng, a rewrite of the classic Tomboy
Re: build 32bit .so with -fPIC
« Reply #4 on: February 03, 2025, 09:27:27 am »
Despite that warning, it still makes a PIE executable.

My app is built in Debian that way for multiple platforms (except Power64el) for several years and does not trigger the dreaded lintian PIE warning.

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018