Closed Thread
Results 1 to 8 of 8

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

  1. #1
    MDM
    MDM is offline Newbie
    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    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
    sudo rm -rf /

  4. #3
    MDM
    MDM is offline Newbie
    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    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?

  5. #4
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    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.
    sudo rm -rf /

  6. #5
    MDM
    MDM is offline Newbie
    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    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.

  7. #6
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    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.
    sudo rm -rf /

  8. #7
    Sysop_fb is offline Programmer
    Join Date
    Apr 2009
    Location
    Missouri
    Posts
    150
    Blog Entries
    2
    Rep Power
    12

    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.

  9. #8
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

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

    I should've known. But yeah, the ROM directive is weird.
    sudo rm -rf /

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Free Wordpress Theme by Tech-Sect
    By ethikz in forum Freebies
    Replies: 0
    Last Post: 08-28-2011, 03:10 PM
  2. [C#] how to read data from a text file
    By Crock in forum Classes and Code Snippets
    Replies: 0
    Last Post: 07-05-2011, 03:35 AM
  3. Trying to learn more about stack/heap/global data
    By blernblan in forum C and C++
    Replies: 2
    Last Post: 06-06-2009, 05:32 PM
  4. Global Variables vs Data Duplicates
    By scc in forum General Programming
    Replies: 4
    Last Post: 07-28-2008, 06:16 PM
  5. Linking Text data to deskop
    By njmase in forum JavaScript and CSS
    Replies: 1
    Last Post: 01-31-2007, 04:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts