Author Topic: Error: A2174: Cannot add two relocatable labels  (Read 1032 times)

KradMoonRa

  • Regular Member
  • *
  • Posts: 24
Error: A2174: Cannot add two relocatable labels
« on: March 12, 2018, 12:01:55 PM »
Hi,

Cant figure out how to bypass this error. A2174: Cannot add two relocatable labels

The project i'm working:

uasmlib

Edit: Found the problem, I need to use the struct's directly in index headers.


Some code: uXmx86Cpua.asm
Code: [Select]

data_layout struct
ok     dword 2 dup(?)
level1 qword 1 dup(?)
level2 qword 1 dup(?)
level3 qword 1 dup(?)
level4 qword 1 dup(?)
descriptortable dword 60 dup(?)
data_layout ends

descriptor_record struct ; record for table of cache descriptors
d_key dword 1 dup(?) ; key from cpuid instruction
d_level dword 1 dup(?) ; cache level
d_sizem dword 1 dup(?) ; size multiplier
d_2pow dword 1 dup(?) ; power of 2. size = d_sizem << d_2pow
descriptor_record ends

_DATA segment ' .data '
;align 16

dataref label ptr qword                              ; reference point
ok_       dd      0, 0                ; 1 when values are determined
level1_   dq      0                   ; level 1 data cache size
level2_   dq      0                   ; level 2 data cache size
level3_   dq      0                   ; level 3 data cache size
level4_   dq      0                   ; level 4 data cache size
numlevels  equ     4                   ; max level

;dlayout data_layout <>   use the struct directly in headers to avoid  Error: A2174: Cannot add two relocatable labels
;drecord descriptor_record <> use the struct directly in headers to avoid  Error: A2174: Cannot add two relocatable labels
_DATA ends

.code
...
...
....
...

        ; loop to search in descriptortable
J200:   
;cmp     eax, [r9 + dlayout.descriptortable + rbx*4 + drecord.d_key]  ;   Error: A2174: Cannot add two relocatable labels
cmp     eax, [r9 + data_layout.descriptortable + rbx*4 + descriptor_record.d_key]
jne     J300
        ; descriptor found
;movzx   eax, byte ptr [r9 + dlayout.descriptortable + rbx*4 + drecord.d_sizem] ;   Error: A2174: Cannot add two relocatable labels
movzx   eax, byte ptr [r9 + data_layout.descriptortable + rbx*4 + descriptor_record.d_sizem]
;mov     ecx,  [r9 + dlayout.descriptortable + rbx*4 + drecord.d_2pow] ;   Error: A2174: Cannot add two relocatable labels
mov     ecx,  [r9 + data_layout.descriptortable + rbx*4 + descriptor_record.d_2pow]
shl     eax, cl                ; compute size
;movzx   ecx, byte ptr [r9 + dlayout.descriptortable + rbx*4 + drecord.d_level] ;   Error: A2174: Cannot add two relocatable labels
movzx   ecx, byte ptr [r9 + data_layout.descriptortable + rbx*4 + descriptor_record.d_level]

...
...
...
« Last Edit: March 12, 2018, 01:32:03 PM by KradMoonRa »

habran

  • Member
  • *****
  • Posts: 1178
    • uasm
Re: Error: A2174: Cannot add two relocatable labels
« Reply #1 on: March 12, 2018, 01:11:29 PM »
As far as I could test it it works fine, however I don't know which src file contains this.
give me the name of source which contains this and I'll check why is it happening
it must be something trivial
Cod-Father

KradMoonRa

  • Regular Member
  • *
  • Posts: 24
Re: Error: A2174: Cannot add two relocatable labels
« Reply #2 on: March 12, 2018, 01:15:17 PM »
Hi habran,

All the source files for the related project i'm working: Here uasmlib  file uXmx86Cpua.asm

habran

  • Member
  • *****
  • Posts: 1178
    • uasm
Re: Error: A2174: Cannot add two relocatable labels
« Reply #3 on: March 12, 2018, 01:18:08 PM »
I need the name of the file which contains this
I can not search all the files to find it
Cod-Father

KradMoonRa

  • Regular Member
  • *
  • Posts: 24
Re: Error: A2174: Cannot add two relocatable labels
« Reply #4 on: March 12, 2018, 01:29:16 PM »

The file: uXmx86Cpua.asm

habran

  • Member
  • *****
  • Posts: 1178
    • uasm
Re: Error: A2174: Cannot add two relocatable labels
« Reply #5 on: March 12, 2018, 03:38:09 PM »
Your structures are inside .code segment, which is wrong ::)
Cod-Father

johnsa

  • Member
  • ****
  • Posts: 710
    • Uasm
Re: Error: A2174: Cannot add two relocatable labels
« Reply #6 on: March 12, 2018, 08:11:02 PM »
You can declare the struct wherever you like, it's just a symbol definition so that should be fine.

I believe the problem is that you are trying to use the address of two separate data items in one instruction, which inherently can only support a single relocation entry.

If you absolutely must use two structures that are guaranteed to be contiguous, you should use a constant distance between the two to reference elements of the second one from a common base.

KradMoonRa

  • Regular Member
  • *
  • Posts: 24
Re: Error: A2174: Cannot add two relocatable labels
« Reply #7 on: March 21, 2018, 02:03:31 PM »
Thanks for the help #johnsa #habran

Now I have the CLASS CPUFeatures working nicely well  with x86 64-bits.

Cleaned up te data to outside of the code segment.

Some work with the register's usage with call convention for the VECTORCALL/SYSTEMV and CLASS proc member, sometimes getting really confused how to push/pop properly the register's. Research.

Indeed the MACROS are our best friend, a-lot of programming task's simplified with predef MACROS.

My wich, it's the UASM CLASS future working with x86 32-bits registers and fastcall convention. 32-bit it's coming to an end, but some old/or VIA hardware or CLOUD/virtual environment still exist with x86 32-bits.

Now it's time to start to work in uasmlib for SSE and AVX features, bringing the slow CPP code to the fast ASM code.