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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:34:10+00:00 2026-05-24T05:34:10+00:00

suppose I have variables: int global a = 1; int banana b = 2;

  • 0

suppose I have variables:

int global a = 1;

int banana b = 2;

int mango c = 3;

I want GCC to generate them such that:

.global
a .long 1
.banana 
b .long 2
.mango
c .long 3

What’s the easiest way to do that?

Updates:

Got:

 __attribute__ ((section ("mmm"))) int a = 432;`

along with

target_asm_named_section()` 

to generate:


    .global
    a: 
       .long 1

Which is great but there are two problems.

One is that unless the lists are ordered for different sections, you’ll get repeat sections.

so


     __attribute__ ((section ("mmm"))) int a = 432;
     __attribute__ ((section ("mmm"))) int b = 432;
     __attribute__ ((section ("global"))) int c = 432;

is good, but


     __attribute__ ((section ("mmm"))) int a = 432;
     __attribute__ ((section ("global"))) int c = 432;
     __attribute__ ((section ("mmm"))) int b = 432;

is bad, because .mmm will appear twice.

The second problem is that I’m already using attributes to do

`__attribute__((global))`

which, to the best of my attempts cannot be combined with the previous attribute.

Is there any easy way to resolve either of those two issues?

  • 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-05-24T05:34:10+00:00Added an answer on May 24, 2026 at 5:34 am

    Solution:
    First use:

    #define MMR __attribute__((section ("section mmr")))

    Then, inside the function defining

    #define TARGET_ENCODE_SECTION_INFO

    navigate to the string via:

        #define ATTRIBUTES(decl) \
          (TYPE_P (decl)) ? TYPE_ATTRIBUTES (decl) \
                        : DECL_ATTRIBUTES (decl) \
                          ? (DECL_ATTRIBUTES (decl)) \
                  : TYPE_ATTRIBUTES (TREE_TYPE (decl))
      tree attr = ATTRIBUTES(decl);
      char* section_name = TREE_STRING_POINTER( TREE_VALUE( TREE_VALUE(attr)));
    

    And viola, the section_name is the phrase you created inside section(“”). Then match it to what you want it to do.

    I use flags for example:

      if(strcmp(section_name, "apple") == 0)
      {
         flags |= SYMBOL_FLAG_APPLE;
      }
    

    The flag being set was the goal of the original _attribute_, and now that it can be done using the section attribute, both goals are achieved with the use of one attribute

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

Sidebar

Related Questions

Okay, suppose I have a bunch of variables, one of them declared volatile: int
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Suppose I have a grammar which takes care of the global variables and some
Suppose I have a program that initializes a global variable for use by threads,
Suppose we have these local variables: int a = 0; int b = 1;
Suppose I have: int a; int b; Are the variables a and b name
Suppose I have a C++ struct that has both POD and non-POD member variables:
Suppose I have a variable of type Int = 08, how can I convert
How do you use variables to access Object attributes? Suppose I have an Object
In Java, suppose I have a String variable S, and I want to search

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.