+ Reply to Thread
Results 1 to 8 of 8

Thread: What is .sect, .data, .text, and .global?

  1. #1
    MDM
    MDM is offline
    Newbie MDM is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    4

    What is .sect, .data, .text, and .global?

    Okay, so I have been learning x86, and I understand most of it, but I don't get what any of the following mean:
    .sect
    .bss
    .data
    .text
    .rom
    .global

    Basically anything that begins with a '.'.

    Any help?

  2. #2
    Moderator dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Posts
    3,427
    Blog Entries
    8

    Re: What is .sect, .data, .text, and .global?

    These just specify the different sections of your program. I'll walk you through each one.
    .sect - Allows you to specify your own kind of section.
    .bss - Reserve space for all your global variables here. These are variables you want to be able to change.
    .data - Reserve space for all your global data here. This means stuff you can't change, like string constants, error messages, etc.
    .text - This is the section where all your executable code goes.

    As for these...what kind of assembler are you using? MASM, TASM, YASM, or something else? I know it's not NASM because it has different syntax for that. I'm not sure what these are.
    .rom
    .global
    find /home -iname 'spammer' -exec shred -z '{}' \;

  3. #3
    MDM
    MDM is offline
    Newbie MDM is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    4

    Re: What is .sect, .data, .text, and .global?

    Thanks!

    I am using the GNU assembler that comes with GCC (I guess that'd be gas). Is there a different one you'd recommend?

  4. #4
    Moderator dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Posts
    3,427
    Blog Entries
    8

    Re: What is .sect, .data, .text, and .global?

    Ah. I don't use that one, though it did come with GCC. I prefer NASM, as it's platform-independent and widely supported. Does GAS force you to use AT&T syntax, or can it accept Intel sytax? I personally abhor AT&T syntax, as it makes no sense.
    find /home -iname 'spammer' -exec shred -z '{}' \;

  5. #5
    MDM
    MDM is offline
    Newbie MDM is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    4

    Re: What is .sect, .data, .text, and .global?

    Yeah, it uses AT&T styled syntax. I'm going to check out NASM because I currently really dislike what I have seen of gas in-general.

  6. #6
    Moderator dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Posts
    3,427
    Blog Entries
    8

    Re: What is .sect, .data, .text, and .global?

    Oh, good. Let me know if you need help or something. I love NASM. Benefits of Intel syntax, by the way:

    AT&T:
    Code:
    leal    $0x80(%esi,%ecx,8), %eax
    Intel:
    Code:
    lea    eax, [ecx*8 + esi + 0x80]
    or alternatively,
    
    lea    eax, [esi + ecx*8 + 0x80]
    
    or this...
    lea    eax, [0x80 + ecx*8+ esi]
    
    ...you get the picture.
    find /home -iname 'spammer' -exec shred -z '{}' \;

  7. #7
    Programmer Sysop_fb is on a distinguished road
    Join Date
    Apr 2009
    Location
    Afghanistan
    Posts
    100

    Re: What is .sect, .data, .text, and .global?

    .global is the same as global in nasm
    It just makes a label externally available to the linker.

    I've never heard of .rom before

    I typed up a post yesterday but I guess it didn't post.
    "The best optimizer is between your ears" - Michael Abrash
    Saying you can optimize a program is like saying you understand how a program works on every level of every facet on a specific machines configuration.

  8. #8
    Moderator dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Posts
    3,427
    Blog Entries
    8

    Re: What is .sect, .data, .text, and .global?

    I should've known. But yeah, the ROM directive is weird.
    find /home -iname 'spammer' -exec shred -z '{}' \;

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Trying to learn more about stack/heap/global data
    By blernblan in forum C and C++
    Replies: 2
    Last Post: 06-06-2009, 04:32 PM
  2. Global Variables vs Data Duplicates
    By scc in forum General Programming
    Replies: 4
    Last Post: 07-28-2008, 05:16 PM
  3. Load / save data from text file
    By wazofski in forum Visual Basic Programming
    Replies: 18
    Last Post: 05-18-2008, 06:54 AM
  4. Program to pass data from text file to table.
    By sania21 in forum Java Help
    Replies: 3
    Last Post: 05-28-2007, 05:32 AM
  5. Linking Text data to deskop
    By njmase in forum JavaScript and CSS
    Replies: 1
    Last Post: 01-31-2007, 04:33 PM