Arm Community
Site
Search
User
Site
Search
User
Groups
Arm Research
DesignStart
Education Hub
Graphics and Gaming
High Performance Computing
Innovation
Multimedia
Open Source Software and Platforms
Physical
Processors
Security
System
Software Tools
TrustZone for Armv8-M
中文社区
Blog
Announcements
Artificial Intelligence
Automotive
Healthcare
HPC
Infrastructure
Innovation
Internet of Things
Machine Learning
Mobile
Smart Homes
Wearables
Forums
All developer forums
IP Product forums
Tool & Software forums
Support
Open a support case
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Developer Community
Tools and Software
Software Tools
Jump...
Cancel
Software Tools
Arm Development Studio forum
Char array and .data section
Tools, Software and IDEs blog
Forums
Videos & Files
Help
Jump...
Cancel
New
Replies
8 replies
Subscribers
126 subscribers
Views
3679 views
Users
0 members are here
Related
Char array and .data section
Offline
Arifa Khan
over 7 years ago
Note: This was originally posted on 11th January 2011 at http://forums.arm.com
Hi,
I've been trying to use string literals in my C code, however I'm having a really odd problem.
I've condensed my code to do just a basic store string literal in a char variable, and output element value:
Code 1:
#include "generic.h"
#include "stdlib.h"
#include "string.h"
int main(void) {
char chartest[4]="HEL";
uart_send_num(chartest[2]); //function I've written to output the numeric value of data, to my serial port
}
Result 1:
0076
So that result is what I expected to see (ASCII : L = 76).
If I change the array size to anything bigger than 4 elements:
Code 2:
#include "generic.h"
#include "stdlib.h"
#include "string.h"
int main(void) {
char chartest[5]="HELL";
uart_send_num(chartest[2]);
}
Result 2:
0000
I can't understand why this would be happening.
I'm using Codesourcery gcc with Eclipse SDK, but still trying to figure out how everything works, so I haven't got all the libraries and maybe even linker script working correctly, i.e. printf, malloc, etc. doesn't work, therefore I wrote my own uart routine.
Part of my linker script is as follows:
.text : {
CREATE_OBJECT_SYMBOLS
*(.text .stub .text.* .gnu.linkonce.t.*)
*(.plt)
*(.gnu.warning)
*(.glue_7t) *(.glue_7) /* NOTE: placed already in .fastcode */
. = ALIGN (4);
/* These are for static constructors and destructors under ELF */
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*crtend.o(.ctors))
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*crtend.o(.dtors))
*(.rodata .stub .rodata.* .gnu.linkonce.r.*)
*(.ARM.extab* .gnu.linkonce.armextab.*)
*(.gcc_except_table)
*(.eh_frame_hdr)
*(.eh_frame)
*(.init)
*(.fini)
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} >ROM
/* .ARM.exidx is sorted, so has to go in its own output section. */
.ARM.exidx : {
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} >ROM
_etext = .;
.data : {
ram_sdata = .;
__data_load = LOADADDR (.data);
__data_start = .;
KEEP(*(.jcr))
*(.got.plt) *(.got)
*(.shdata)
PROVIDE(_sdata = . );
*(.data .stub .data.* .gnu.linkonce.d.*)
. = ALIGN(4);
. = ALIGN (4);
PROVIDE(_edata = . );
_edata = .;
} >RAM AT>ROM
.bss : {
__bss_start = . ;
*(.shbss)
*(.bss .stub .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN (4);
PROVIDE(_sbss = . );
*(.bss)
. = ALIGN(4);
PROVIDE(_ebss = . );
__bss_end = .;
} >RAM
PROVIDE(__heap_start__ = __bss_end );
__HEAPSIZE__ = 4097;
I'm presuming it's something to do with my linker script?
I've tried searching for a similar problem, but nothing relevant seems to come up. Would anyone have any suggestions or ideas on what may be the problem?
At this point, even any guesses would be more than welcome!
Thanks!
More questions in this forum
By title
By date
By reply count
By view count
By most asked
By votes
By quality
Descending
Ascending
All recent questions
Unread questions
Questions you've participated in
Questions you've asked
Unanswered questions
Answered questions
Questions with suggested answers
Questions with no replies
Answered
DS52020.0 connection to Musca-A/B boards not working
+1
Arm Development Studio
Musca-A
7451
views
4
replies
Latest
2 months ago
by
Daniel Oliveira
Answered
Positioning a function in a Position Independent Executable for ARMV8
+1
8017
views
3
replies
Latest
3 months ago
by
Stephen Theobald
Answered
Link a pure binary file to image with scatter file
0
7998
views
3
replies
Latest
3 months ago
by
Ronan Synnott
Answered
Failed to read contents of Internal RAM L1-I_DATA in ARM DS
0
Arm Development Studio
Cache
Debug and Trace Services Layer (DTSL)
13098
views
23
replies
Latest
3 months ago
by
Boon Khai
Answered
DS-5 connect fail when cortex-r5 is in lock-step mode
+1
10862
views
10
replies
Latest
3 months ago
by
Stuart Hirons
<
>
View all questions in Arm Development Studio forum