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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:35:44+00:00 2026-05-26T08:35:44+00:00

I have just noticed that my simple program has its data and stack segments

  • 0

I have just noticed that my simple program has its data and stack segments executable.
I saw it in /proc/[pid]/maps, and simple code confirmed it.

For example:

; prog.asm
section .data
    code:   db 0xCC    ;int3

section .text
global _start
_start:
    jmp    code

    mov    rax, 60    ; sys_exit
    mov    rdi, 0
    syscall

then

nasm -f elf64 prog.asm
ld -o prog prog.o
./prog

causes prog to execute int3 instruction.

Programs written in C and built with gcc have their data, stack and heap non-executable, so why those written in assembly behave in a different manner?

  • 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-26T08:35:45+00:00Added an answer on May 26, 2026 at 8:35 am

    On modern Linux systems, the linker will mark stack/data non-executable IFF all objects that participate in the link have a special "marker" section .note.GNU-stack.

    If you compile e.g. int foo() { return 1; } into assembly (with gcc -S foo.c), you’ll see this:

        .section    .note.GNU-stack,"",@progbits
    

    For nasm, the syntax is shown in section 8.9.2 of the manual; you want something like this:

     section .note.GNU-stack noalloc noexec nowrite progbits
    

    Note

    This has to be done for every .o file that goes into the executable. If any object file needs executable stack or data, then it’s set for the entire segment.

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

Sidebar

Related Questions

I have just noticed that a multidimensional array in C# does not implement IEnumerable<T>
I have just noticed that my ViewController does not call init (See below) when
I just noticed that if I have an identity column in a table, when
I'm using protobuf-net r278 in C#, and I just noticed that if I have
I've noticed that just in the last year or so, many major websites have
I have noticed that the Windows Vista/7 dialogs look MUCH better than just a
I just started using Qt and noticed that all the example class definitions have
I've recently began using dTrace and have noticed just how awesome it is. Its
I noticed that when I build even a very simple Java program in Eclipse,
Just noticed that Opengl ES 1.0, 1.1, and probably also 2.0 don't have an

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.