27 February 2024, 22:54 | #1 |
Registered User
Join Date: Jun 2009
Location: United States
Posts: 57
|
vasm - Illegal relocation for basereg on merged BSS
Code:
XREF _LinkerDB NEAR a4 SECTION __MERGED,DATA _DataStart: SomeData: dcb.b 64 SECTION __MERGED,BSS SomeBSS: dcb.b 64 BASEREG _DataStart,a3 CODE _start: movem.l d0-a6,-(sp) lea _DataStart,a3 move.l SomeData(a3),d0 ; This works move.l SomeBSS(a3),d0 ; Illegal relocation The NEAR directive handles this just fine, and I'm curious what the difference is. When using NEAR, do all data references turn into relocation entries that resolve at load time? Or does vlink resolve all the base-relative offsets ahead of time, with only _LinkerDB requiring relocation? Basically, I'm wondering if vasm can somehow understand that the __MERGED data and BSS sections will be in contiguous memory, and allow BASEREG to flow from one into the other. But maybe I'm misunderstanding something, and "-sd" does not in fact guarantee that they are contiguous. I appreciate any insight. |
27 February 2024, 23:29 | #2 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,975
|
I dont use vasm, but bss section can contains only zero/null bytes. Maybe dont likes BASEREG inside. You can change section from BSS to DATA and check.
|
28 February 2024, 05:58 | #3 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,231
|
Quote:
|
|
28 February 2024, 09:42 | #4 |
Registered User
Join Date: Dec 2023
Location: 3rd Rock From The Sun
Posts: 10
|
Solution provided for clean "error free" assembly only, NOT tested for desired behaviour.
Changes mad are in bold. Code:
XREF _LinkerDB NEAR a4 SECTION __MERGED,DATA _DataStart: RSRESET SomeData: rs.b 64 SECTION __MERGED,BSS SomeBSS: rs.b 64 BASEREG _DataStart,a3 CODE _start: movem.l d0-a6,-(sp) lea _DataStart,a3 move.l SomeData(a3),d0 ; This works move.l SomeBSS(a3),d0 ; Illegal relocation |
28 February 2024, 14:48 | #5 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
-sdis not meant to merge sections. Sections named __MERGEDare always merged by any real AmigaDOS linker (like blink, slink, phxlnk, vlink, etc.), sorted by type (Data first, then BSS). Confusingly, there is also a -sdoption in vlink, which will indeed merge all Data and BSS sections, regardless of name. What -sddoes in vasm is just to enable optimization of symbolto symbol(a4), whenever the symbol is from such a small-data section (named __MERGED) and the base register is the same as specified by the neardirective. It has no relevance in this case. Quote:
BASEREGis a different concept than regular small-data. It can only access data from the section where the base-symbol (here _DataStart) is defined in, via the given base register. Quote:
NEARdirective) creates relocations entries, which the linker will resolve. BASEREGonly works locally, with a single section, and does not create relocations. Quote:
|
|||
28 February 2024, 20:11 | #6 | |
Registered User
Join Date: Jun 2009
Location: United States
Posts: 57
|
Quote:
-sdbeing an option in both vasm and vlink, and the name __MERGEDbeing used for both Data and BSS sections. I understand now that vasm has no visibility/understanding that the linker will merge the sections. There are a couple more things I'm wondering about, but it's part of a bigger question with more dedicated discussion, so I will create a new thread. The main question in this thread has been answered—thank you! |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VASM and illegal relocations | reassembler | Coders. Asm / Hardware | 18 | 19 January 2024 17:03 |
vasm relocation error | BippyM | Coders. Asm / Hardware | 18 | 08 August 2022 18:37 |
VASM/VLINK relocation issues | pipper | Coders. Asm / Hardware | 31 | 22 May 2021 12:03 |
vasm basereg example directive | mcgeezer | Coders. Asm / Hardware | 7 | 18 November 2020 19:58 |
Merged Dats | BippyM | project.TOSEC (amiga only) | 4 | 01 November 2018 12:29 |
|
|