Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:06:26+00:00 2026-06-01T23:06:26+00:00

i recently started assembler programming for arm cores. My first little demos, only with

  • 0

i recently started assembler programming for arm cores. My first little demos, only with the .text section, ran without any problems.

As a logical extension i wanted to structure the assembler code into the usual sections: .text, .data, .bss .

So i wrote the following simple program:

 .globl _start

 .section .text

 _start:
     b   main
     b   .
     b   .
     b   .
     b   .
     b   .
     b   .
     b   .  


 main:
    ldr r0, x
    nop

 .section .data

 x:  .word  0xf0f0f0f0

 .end

But

  /opt/arm/bin/arm-as -ggdb -mcpu=arm7tdmi demo.s -o demo.o

exits with the error

 prog.s: Assembler messages:
 prog.s:17: Error: internal_relocation (type: OFFSET_IMM) not fixed up
 make: *** [prog.o] Error 1

I have no clue why the assembler complains about relocation, because i thought that’s the task of the linker. I could imagine that i have to tell the assembler that my .data section isn’t located at the final memory postion at the assembling stage, but i can’t find anything related.

Although i found a way to get the code assembled correctly, by replacing

 .section .data

by

 .org .

that is not a satisfying solution. Especially in view of the fact that the gas documentation highlight the sense of this section.

Maybe someone of you experts can help me to gain some wisdom

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:06:28+00:00Added an answer on June 1, 2026 at 11:06 pm

    It seems the only way you can do it is by grabbing the address of the variable and load a value from that address.

    ldr r1,=x    ; get address of x
    ldr r0,[r1]  ; load from that address
    

    In a way, this also kind of makes sense. After all, what if the address of x (after linking) is too far away for a PC relative access? Since the compiler (which doesn’t do the linking) does not know how far away the data section may be from the text section, it would refuse to compile that code just in case it isn’t reachable.

    By using this indirect way of accessing a variable, it is guaranteed that the variable will be reachable (or at least the compiler can be sure whether the variable is reachable or not).

    Code adapted from http://www.zap.org.au/elec2041-cdrom/examples/intro/pseudo.s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently started with x86 assembler, but I can't find any method to know
I recently started diving into low level OS programming. I am (very slowly) currently
Recently started programming Android Java (Eclipse), Im trying to make a simple reader app
I recently started game programming on the iPhone using Cocos2d and Box2d. So here's
I recently started backend programming with Java servlets to access data for intranet webapps.
I recently started learning 0MQ . Earlier today, I ran into a blog, Python
I recently started getting this error while running gems or bundler. The only thing
I recently started using the Yii framework trying to learn a little bit more
I recently started using IConfigurationSectionHandler as a custom configuration section for my BL DLL.
I recently started work on a personal coding project using C++ and KDevelop. Although

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.