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 8774215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:30:19+00:00 2026-06-13T18:30:19+00:00

Using Codesourcery arm-linux-eabi crosscompiler and have problems with the compiler not executing certain code

  • 0

Using Codesourcery arm-linux-eabi crosscompiler and have problems with the compiler not executing certain code because it thinks it’s not used, especially for a systemcall. Is there any way to get around this?

For example this code does not initialize the variable.

unsigned int temp = 42;
asm volatile("mov R1, %0 :: "r" (temp));
asm volatile("swi 1");

In this case temp never get initialized to the value 42. However if I add a printk after the initialization, it gets initialized to the correct value 42. I tried with

unsigned int temp __attribute__ ((used)) = 42;

Still doesn’t work but I get a warning message:

‘used’ attribute ignored [-Wattributes]

this is in the linux kernel code.

Any tips?

  • 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-13T18:30:21+00:00Added an answer on June 13, 2026 at 6:30 pm

    This is not the correct way to use inline assembly. As written, the two statements are separate, and there is no reason the compiler has to preserve any register values between the two. You need to either put both assembly instructions in the same inline assembly block, with proper input and output constraints, or you could do something like the following which allows the compiler to be more efficient:

    register unsigned int temp __asm__("r1") = 42;
    __asm__ volatile("swi 1" : : "r"(temp) : "memory");
    

    (Note that I added memory to the clobber list; I’m not sure which syscall you’re making, but if the syscall writes to any object in userspace, “memory” needs to be listed in the clobberlist.)

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

Sidebar

Related Questions

I am trying to configure util-linux to cross compile using arm-none-linux-gnueabi from CodeSourcery. My
I am using the CodeSorcery arm-eabi-gcc tool chain and I have a problem using
I have installed Eclipse CDT, CodeSourcery G++ toolchain on Linux host. I am using
I want to build a static hello world from C using arm-linux-gnueabi-gcc as opposed
I have this part of code that was compiling using ARMASM : /* Software
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have a ARM NEON Cortex-A8 based processor target. I was optimizing my code
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using MVC2 I have an AJAX form which is posting to a bound model.
Using SolrNet for querying & faceting. I have a combination of int, tdate and

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.