English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. C/C++ (http://eab.abime.net/forumdisplay.php?f=118)
-   -   vbcc bss clearing issue (http://eab.abime.net/showthread.php?t=89661)

dalton 01 December 2017 22:03

vbcc bss clearing issue
 
I've been having some trouble with constant data included in my program being cleared already before my program starts running.

So I disassembled to linked executable of my program, and found this piece of code just 5 rows into the program. It is a loop which iterates 0x30 (48) times. Each time clearing one longword.
Code:

        MOVE.L        #$00000030,D0
        BEQ.S        LAB_0002
        LEA        __BSSBAS,A0
LAB_0001:
        CLR.L        (A0)+
        SUBQ.L        #1,D0
        BNE.S        LAB_0001
LAB_0002:

Further down the source is the __BSSBAS declaration:

Code:

        SECTION S_2,DATA

SECSTRT_2:
        DC.L        $00220063,$41000000
__BSSBAS:
        DS.L        1
_SysBase:
        DS.L        1
_DOSBase:
        DS.L        1
_WBenchMsg:
        DS.L        1
__WBenchMsg:
        DS.L        1
__stdin:
        DS.L        1
__stdout:
        DS.L        1
__stderr:
        DS.L        1
_errno:
        DS.L        1
___stack_usage:
        DS.L        1
___stackLower:
        DS.L        1
___stackPtr:
        DS.L        1


        SECTION S_3,DATA

SECSTRT_3:
        DS.L        1
_GfxBase:
        DS.L        1

There are 12 longwords from __BSSBAS to the end of the section, ie 48 (0x30) bytes.

The clearing loop in the beginning of the program appears to be clearing 4 times the data it should. So it basically goes on to clear some constant data I have included in my program.

Very strange! Is it a bug in vbcc?

VBCC 0.9e

dalton 02 December 2017 20:20

This title of this post is actually not accurate. It's not clearing bss data, it's clearing a normal data section which happens to hold a bss pointer.

Still, I'm pretty confident it's a bug in the m68k-kick13 targets startup.o.
It basically clears a number of longwords instead of that number of bytes.

phx 02 December 2017 21:36

Quote:

Originally Posted by dalton (Post 1203396)
The clearing loop in the beginning of the program appears to be clearing 4 times the data it should. So it basically goes on to clear some constant data I have included in my program.

Very strange! Is it a bug in vbcc?

Don't think so. My guess is that you are using an obsolete vlink version for m68k-kick13.

In my startup code source the "move.l #$00000030,d0" is
Code:

        move.l  #__BSSLEN,d0
__BSSLEN is a (SAS/C-compatible) linker symbol, which represents the number of long words in the BSS part of a Data-Bss section. There was a bug fix for vlink recently (before the vbcc 0.9f release). From the history file:
Code:

- 0.16 (16.05.17)
...
o (ados/ehf): Fixed SAS/C-compatibility linker symbol __BSSLEN. Now it
  represents the number of long words instead of the number of bytes.
  WARNING! Make sure to check your code, if you used __BSSLEN before!

Make sure your vlink is V0.16.


Quote:

VBCC 0.9e
Hmm. There was no m68k-kick13 target in 0.9e. I first released it with 0.9f (accompanied by the appropriate vlink-version).

dalton 02 December 2017 22:50

I see! It looks like I have mismatched target and linker versions. I've actually been changing back and forth between different compiler/linker versions without considering the targets.
Thanks for your reply!


All times are GMT +2. The time now is 21:36.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.04929 seconds with 11 queries