This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libgloss/v850/crt0.S missing copy of .data from ROM to RAM?

Hi Nick,

Thank you for your quick response.

In my case I made a very simple implementation and payed no special
attention to the .zdata, .sdata and .tdata sections (but I also made
sure GCC would not output data to these sections). Perhaps the resulting
code is not as efficient as it could be, but it was easier to implement
and test it that way. I put the ram_data_start-symbol and the
ram_data_end-symbol such that the .data1 section was included in my
CRT's code, as well as some other sections like: .ctors, .dtors, .sdata.

I think a patch submission would have to include a memory layout in the
linker script as well as assignment of sections to defined memory
regions, e.g., "> RAM at ROM". For my simple project, the binary is
flashed via a bootloader and executed directly without any underlying
OS. If the current linker script in libgloss together with the CRT
routines has been working fine (I guess resulting binaries are usually
run from an OS that loads them into RAM, like Linux?), I really do not
want to risk ruining it for others. Since the V850 architecture is quite
special, perhaps a comment or two in the source code would suffice,
notifying the user that the copying from ROM to RAM has to be done manually?


Josef Larsson

Den 2016-05-24 kl. 17:59, skrev Nick Clifton:
> Hi Josef,
>> I have built GCC 4.9.2 together with newlib-2.2.0-1, which I then used
>> for a v850 project. I experienced problems with the resulting binary I
>> tried to flash. After some digging around I could not find any code
>> copying the .data section from ROM to RAM, but I did find code in crt0.S
>> clearing .bss.
>> Am I right in assuming that the code is missing in crt
> Yes.
>> or should it not even be there (where else?)?
> No, crt0 is the right place for this code.
> Obviously this problem has arisen because no-one thought about the
> possibility that the data sections might be loaded at a different
> address from the their runtime locations.  It should be fairly
> straightforward to extend the assembler in crt0.S to support this
> requirement however.  Would you like to submit a patch ?
> Presumably there may also be a need to copy the .zdata, .tdata and
> .sdata sections.  I also see that there is a .data1 section, although
> I do not know if it is ever used.
> Cheers
>    Nick

Josef Larsson
Systems Engineer

NIRA Dynamics AB
Wallenbergs gata 4
58330 LinkÃping

Phone: +46 13 491 98 11
Mobile: +46 767 860 739 - Together for smarter safety

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]