Recent

Author Topic: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER  (Read 656 times)

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« on: October 28, 2024, 04:16:57 pm »
Code: Text  [Select][+][-]
  1. app.lpr(43,1) Error: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
  2. app.lpr(43,1) Error: Undefined symbol: XMM_::=::\_XFREEMEM$POINTER::=::\LONGWORD
  3. app.lpr(43,1) Error: Undefined symbol: XMM_::=::\_XREALLOCMEM$POINTER$LONGWORD::=::\POINTER
  4. app.lpr(43,1) Error: Undefined symbol: XMM_::=::\_XMEMSIZE$POINTER::=::\LONGWORD
  5. app.lpr(43,1) Verbose: There were 4 errors compiling module, stopping
  6. Verbose: Compilation aborted

This doesn't just happen occasionally; its on EVERY subsequent compilation. Clean builds are ok, but otherwise its 100% reproducible.

Here's the setup:

XMM is a unit, and its in the "uses" in the implementation section of "system.pas". In "system.pas" there are functions like "GetMem" that use XMM functions; for example "GetMem" calls "xgetmem".

I have no idea how to fix this. One option might be to not use "uses" and put everything in "system.pas" (perhaps as included files), but having it in "uses" is more convenient if update of XMM unit is required.

If that makes any difference, XMM is a memory manager I made; its used elsewhere, but in this case, its for a custom RTL. The original system.pas/pp doesn't use "uses" at all, maybe it cant, or shouldn't? But it does compile and run fine, just not reusable. Only clean builds work.

EDIT: FPC 3.2.2
« Last Edit: October 28, 2024, 05:07:49 pm by Fibonacci »

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #1 on: October 28, 2024, 04:35:24 pm »
Found out something.

I have this structure:

Code: Pascal  [Select][+][-]
  1.   PMemoryManager_test = ^TMemoryManager_test;
  2.   TMemoryManager_test = record
  3.     NeedLock:         boolean; // obsolete
  4.     GetMem:           function(size: ptruint): pointer;
  5.     FreeMem:          function(p: pointer): ptruint;
  6.     FreeMemSize:      function(p: pointer; size: ptruint): ptruint;
  7.     AllocMem:         function(size: ptruint): pointer;
  8.     ReAllocMem:       function(var p: pointer; size: ptruint): pointer;
  9.     MemSize:          function(p: pointer): ptruint;
  10.     InitThread:       procedure;
  11.     DoneThread:       procedure;
  12.     RelocateHeap:     procedure;
  13.     GetHeapStatus:    function: THeapStatus;
  14.     GetFPCHeapStatus: function: TFPCHeapStatus;
  15.   end;

Below is

Code: Pascal  [Select][+][-]
  1. var
  2.   MemoryManager_test: TMemoryManager_test;

And get this. If I comment this out, subsequent compiles works fine, no symbol errors, no problems.

This variable isnt used AT ALL nowhere. If this is NOT commented out, the errors with symbols happen. I checked xmm.o and there are symbols:

Code: Text  [Select][+][-]
  1. Offset  Size    Type    String
  2. 1a5c    39      A       .text.n_xmm_$$__xgetmemchunk$longword$$memorymanager_test
  3. 1a96    33      A       .text.n_xmm_$$_xgetmem$longword$$memorymanager_test
  4. 1ee7    2b      A       XMM_$$_XGETMEM$LONGWORD$$MEMORYMANAGER_TEST
  5. 230b    39      A       .text.n_xmm_$$__xgetmemchunk$longword$$memorymanager_test
  6. 2345    33      A       .text.n_xmm_$$_xgetmem$longword$$memorymanager_test

It somehow attaches XMM rountines to this variable, what..?

Not used variable gets commented out, and xmm.o has these symbols:

Code: Text  [Select][+][-]
  1. Offset  Size    Type    String
  2. 1a5c    2e      A       .text.n_xmm_$$__xgetmemchunk$longword$$pointer
  3. 1a8b    28      A       .text.n_xmm_$$_xgetmem$longword$$pointer
  4. 1e0b    20      A       XMM_$$_XGETMEM$LONGWORD$$POINTER
  5. 2169    2e      A       .text.n_xmm_$$__xgetmemchunk$longword$$pointer
  6. 2198    28      A       .text.n_xmm_$$_xgetmem$longword$$pointer
« Last Edit: October 28, 2024, 04:37:33 pm by Fibonacci »

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #2 on: October 28, 2024, 04:36:36 pm »
This is not a FPC problem.
This maybe that your compiler proxy application does not regex work.

My suggestion would be, to look into the sources, and search for similar names
- also generate assembly, and check

FPC don't work with :: or \_ \Pointer  ...

This are syntax Errors by parsing.
I don't know which state it is - assembly or linking.
But I would guess its assembly.

Because the strings looks like, if you have tried to use escaped strings...
a look over on the fly:

\P is definitive not escaped string char.

But \_ could be.

And ::=:: are definitive not ISO US ASCII 7-Bit name conventions for linker symbols.

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #3 on: October 28, 2024, 04:45:15 pm »
This is not a FPC problem.
This maybe that your compiler proxy application does not regex work.

My suggestion would be, to look into the sources, and search for similar names
- also generate assembly, and check

FPC don't work with :: or \_ \Pointer  ...

This are syntax Errors by parsing.
I don't know which state it is - assembly or linking.
But I would guess its assembly.

Because the strings looks like, if you have tried to use escaped strings...
a look over on the fly:

\P is definitive not escaped string char.

But \_ could be.

And ::=:: are definitive not ISO US ASCII 7-Bit name conventions for linker symbols.

Unfortunately you are not right. I changed Project Options to not use proxy, I used the compiler directly. Same thing. Proxy only makes the IDE work properly: finding fpc.cfg, listing custom options etc.

Here is the output if I compile using console.

Code: Pascal  [Select][+][-]
  1. (9015) Linking D:\<cut>\project0\app.exe
  2. D:\<cut>\project0\app.lpr(43,1) Error: Undefined symbol: XMM_D:=D:\<cut>\project0_XGETMEM$LONGWORDD:=D:\<cut>\project0POINTER
  3. D:\<cut>\project0\app.lpr(43,1) Error: Undefined symbol: XMM_D:=D:\<cut>\project0_XFREEMEM$POINTERD:=D:\<cut>\project0LONGWORD
  4. D:\<cut>\project0\app.lpr(43,1) Error: Undefined symbol: XMM_D:=D:\<cut>\project0_XREALLOCMEM$POINTER$LONGWORDD:=D:\<cut>\project0POINTER
  5. D:\<cut>\project0\app.lpr(43,1) Error: Undefined symbol: XMM_D:=D:\<cut>\project0_XMEMSIZE$POINTERD:=D:\<cut>\project0LONGWORD
  6. D:\<cut>\project0\app.lpr(43,1) Fatal: (10026) There were 4 errors compiling module, stopping
  7. Fatal: (1018) Compilation aborted

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #4 on: October 28, 2024, 04:50:08 pm »
is that your Compiler implementation ?
have you tried other Compilers ?

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #5 on: October 28, 2024, 04:55:09 pm »
is that your Compiler implementation ?
have you tried other Compilers ?

Official 3.2.2

In "system.s" the only change if I uncomment the variable is this (added), nothing else.

Code: ASM  [Select][+][-]
  1. .section .bss
  2.         .balign 4
  3. # [339] MemoryManager_test2: TMemoryManager_test2;
  4.         .globl U_$SYSTEM_$$_MEMORYMANAGER_TEST2
  5. U_$SYSTEM_$$_MEMORYMANAGER_TEST2:
  6.         .zero 48

But in "xmm.s" there are changes everywhere

Code: ASM  [Select][+][-]
  1. .section .text.n_xmm_$$_xgetmem$longword$$pointer,"x"
  2.         .balign 16,0x90
  3. .globl  XMM_$$_XGETMEM$LONGWORD$$POINTER
  4. XMM_$$_XGETMEM$LONGWORD$$POINTER:

Changed to

Code: ASM  [Select][+][-]
  1. .section .text.n_xmm_$$_xgetmem$longword$$memorymanager_test2,"x"
  2.         .balign 16,0x90
  3. .globl  XMM_$$_XGETMEM$LONGWORD$$MEMORYMANAGER_TEST2
  4. XMM_$$_XGETMEM$LONGWORD$$MEMORYMANAGER_TEST2:

By only uncommenting the variaible, nothing else. XMM unit has no "MemoryManager" word in it.

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #6 on: October 28, 2024, 04:59:52 pm »
If I comment last 3 items in this record then NO ERRORS:

Code: Pascal  [Select][+][-]
  1.   TMemoryManager_test2 = record
  2.     NeedLock:         boolean; // obsolete
  3.     GetMem:           function(size: ptruint): pointer;
  4.     FreeMem:          function(p: pointer): ptruint;
  5.     FreeMemSize:      function(p: pointer; size: ptruint): ptruint;
  6.     AllocMem:         function(size: ptruint): pointer;
  7.     ReAllocMem:       function(var p: pointer; size: ptruint): pointer;
  8.     MemSize:          function(p: pointer): ptruint;
  9.     InitThread:       procedure;
  10.     DoneThread:       procedure;
  11.     //RelocateHeap:     procedure;
  12.     //GetHeapStatus:    function: THeapStatus;
  13.     //GetFPCHeapStatus: function: TFPCHeapStatus;
  14.   end;

Whaaaaaat..

If I change it like that:

Code: Pascal  [Select][+][-]
  1.     RelocateHeap:     integer;
  2.     GetHeapStatus:    integer;
  3.     GetFPCHeapStatus: integer;  

No change, still errors.

Blows my mind :o

I dont need this structure in my RTL anyway, I guess I will just remove it. But what is going on!?
« Last Edit: October 28, 2024, 05:08:46 pm by Fibonacci »

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #7 on: October 28, 2024, 05:03:20 pm »
either you use Pointer only or
either you use Word for all.

It is design question:
- With WORD you are limited to 16 bit
- With Pointer you are limited to 32-Bit on x86
- With Pointer you are limited to 64-Bit on x86_64

where Pointer can be anything 16,32, and 64.
So you have to Cast variables.

BTW:
U_$ and n_  are created by FPC - don't try to change it

paule32

  • Sr. Member
  • ****
  • Posts: 280
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #8 on: October 28, 2024, 05:07:31 pm »
RelocateHeap:     procedure;

could be 32 bit on i386
could be 64 bit on amd64

either you use SIZE_T or DWORD on 32 bit
or you use QWORD on 64 bit

where SIZE_T is a placeholder for 32, and 64 bit

seems you do a mix of 32 and 64 bit stuff.

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #9 on: October 28, 2024, 05:11:40 pm »
RelocateHeap:     procedure;

could be 32 bit on i386
could be 64 bit on amd64

either you use SIZE_T or DWORD on 32 bit
or you use QWORD on 64 bit

where SIZE_T is a placeholder for 32, and 64 bit

seems you do a mix of 32 and 64 bit stuff.

What u talking about? I dont use this structure, ever, anywhere. I DO NOT USE, DO NOT ASSIGN MY ROUNTINES. No use AT ALL. Ok?

A variable of this type exists = symbol errors. On subsequent compilations, first one is okay.

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #10 on: October 28, 2024, 05:21:42 pm »
Code: Pascal  [Select][+][-]
  1. type
  2.   arecord = record
  3.     renamed1: boolean;
  4.     renamed2: boolean;
  5.     renamed3: boolean;
  6.     renamed4: boolean;
  7.     renamed5: boolean;
  8.     renamed6: boolean;
  9.     renamed7: boolean;
  10.     renamed8: boolean;
  11.     renamed9: boolean;
  12.     renamed10: boolean;
  13.     renamed11: boolean;
  14.     renamed12: boolean;
  15.   end;
  16.  
  17. var
  18.   avariable: arecord;

This code causes symbol errors.

Symbol in xmm.o: .text.n_xmm_$$_xgetmem$longword$$avariable

Reminder: "uses xmm;" is right below "implementation" in "system.pas".

Now, 1 item is enough to comment out to stop the errors.

Code: Pascal  [Select][+][-]
  1. type
  2.   arecord = record
  3.     //renamed1: boolean;
  4.     renamed2: boolean;
  5.     renamed3: boolean;
  6.     renamed4: boolean;
  7.     renamed5: boolean;
  8.     renamed6: boolean;
  9.     renamed7: boolean;
  10.     renamed8: boolean;
  11.     renamed9: boolean;
  12.     renamed10: boolean;
  13.     renamed11: boolean;
  14.     renamed12: boolean;
  15.   end;
  16.  
  17. var
  18.   avariable: arecord

Again: mind blown!

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #11 on: October 28, 2024, 05:41:45 pm »
First compilation: XMM_$$__XGETMEMCHUNK$LONGWORD$$POINTER
Next compilation:  XMM_$$__XGETMEMCHUNK$LONGWORD$$LAST_VARIABLE_BEFORE_IMPLEMENTATION


All pointers now became "var last_variable_before_implementation: integer;"

I guess perhaps Ill make a small POC and report this as an issue.

Thaddy

  • Hero Member
  • *****
  • Posts: 16193
  • Censorship about opinions does not belong here.
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #12 on: October 28, 2024, 05:43:20 pm »
@Fibonacci
For that to work you have to actually specify it: -Cf<xxx>
If you don't it will not get used.
Check fpc -if for the options and check your computer if it actually supports that version, because the compiler can generate code even for cpu's that your own cpu might not support.
« Last Edit: October 28, 2024, 05:45:30 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Fibonacci

  • Hero Member
  • *****
  • Posts: 612
  • Internal Error Hunter
Re: Undefined symbol: XMM_::=::\_XGETMEM$LONGWORD::=::\POINTER
« Reply #13 on: October 28, 2024, 05:55:09 pm »
@Fibonacci
For that to work you have to actually specify it: -Cf<xxx>
If you don't it will not get used.
Check fpc -if for the options and check your computer if it actually supports that version, because the compiler can generate code even for cpu's that your own cpu might not support.

Code: Text  [Select][+][-]
  1. > fpc-3_2_2-i386-win32-ppc386.exe -if
  2. X87
  3. SSE
  4. SSE2
  5. SSE3
  6. SSSE3
  7. SSE41
  8. SSE42
  9. AVX
  10. AVX2

Tried all of them with -Cf, no difference.

Ill get 3.2 fixes with fpcupdeluxe and check with that compiler.
« Last Edit: October 28, 2024, 06:00:16 pm by Fibonacci »

 

TinyPortal © 2005-2018