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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:23:13+00:00 2026-06-03T16:23:13+00:00

I found that when we use nested functions , GCC requires an executable stack

  • 0

I found that when we use nested functions, GCC requires an executable stack for trampoline code. However, following code, when compiled using gcc doesn’t show an executable stack. (I used execstack to verify if the stack is executable)

#include <stdio.h>
#include <unistd.h>

int main()
{
        int add( int a, int b)
        {
                return a + b;
        }
        return add(2, 3);
}

Why does this not result in a executable stack? And if it is not supposed to, then can someone give example of a code construct that does give an executable stack?

  • 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-03T16:23:15+00:00Added an answer on June 3, 2026 at 4:23 pm

    If the nested function doesn’t depend in its “parent”‘s stack at all, then it’s just a plain function – the nesting is syntactic (and scoping) sugar.

    And if you don’t take the address of the nested function, no trampoline code is necessary either. So you’ll need something a bit more involved to trigger all that.

    Here’s a dummy example:

    // file t.c
    int doit(int (*fun)(int), int x)
    {
        return fun(x);
    }
    
    int foo(int a)
    {
            int add(int b)
            {
                    return a + b;
            }
            return doit(&add, 2);
    }
    
    int main(void)
    {
        return foo(1);
    }
    
    $ gcc -Wtrampolines t.c
    t.c: In function 'foo':
    t.c:8:13: warning: trampoline generated for nested function 'add'
    $ ./a.out 
    $ echo $?
    3
    $ execstack a.out 
    X a.out
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to use code I've found that uses Win32. However, I'm getting this
From what I've found in C#, the Control.Invoke method requires that you use a
I mostly use lambda functions but sometimes use nested functions that seem to provide
I found out that I can use a different theme in an C# WPF
I've found that in order to use PRISM's classes in XAML you need to
I haven't found any references to apps that use a custom activity indicator --
I tried to use $.cssRule() plugin and found that it makes it inconvenient to
We want to use Unicode with Delphi 2009 and Interbase, and found that to
In attempting to use std::select1st from <functional> in a VS2008 project I found that
I found it very hard to customize PDF invoice that Magento use. Not only

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.