4

A book I am reading refers to an include file that shows how a stack frame looks on one's UNIX system.

In particular: /usr/include/sys/frame.h

I am having trouble finding the modern equivalent. Anyone have an idea? I'm on Ubuntu 12.10.


By the way, it is a description of stack frames and activation records that I want--not necesssarily that relic of a file. That information was stored in that file, "back in the day", though.

d0rmLife
  • 153
  • 1
  • 1
  • 7
  • Maybe `arch/x86/include/asm/frame.h` in your kernel headers directory? (assuming you're on an x86 system, of course.) – user55325 Mar 07 '13 at 07:04
  • Now that I look at it, and keeping in mind that I'm not really familiar with this low-level kernel kind of thing, `sigframe.h` in the same directory looks more likely... hopefully someone with some expertise will come up with a real answer though. – user55325 Mar 07 '13 at 07:13
  • @user55325 your first suggestion is **definitely a good lead**, just took a look at it. However, I'm not *fully convinced* it is what my author had in mind... let's see what others have to say! – d0rmLife Mar 07 '13 at 18:56

1 Answers1

2

You might want to have a look at the ptrace.h and calling.h files, which have some C-structures defining the stack frame layout and calling conventions (they can be found in the same folders as frame.h). Furthermore, the elfcore.h header file included with the gperftools project may provide some useful insight into the call-stack frames.

Also if you're so inclined, you might want to look at the x86 Assembly and x86 Disassembly books on Wikibooks. They have quite a lot of useful information (both high and low level) regarding stack frames and calling convention details.


In terms of frame.h, calling sudo find / -name "frame.h" on my Xubuntu 12.04 install returns the following:

/usr/src/linux-headers-3.2.0-23/arch/x86/include/asm/frame.h
/usr/src/linux-headers-3.2.0-33/arch/x86/include/asm/frame.h
/usr/src/linux-headers-3.2.0-35/arch/x86/include/asm/frame.h
/usr/src/linux-headers-3.2.0-34/arch/x86/include/asm/frame.h

Not surprisingly, there is no change to the file between the kernel versions listed above, and it's unlikely you would see any changes for compatibility reasons (of course, this depends on what architecture your system is).

Breakthrough
  • 34,227
  • 10
  • 105
  • 149
  • Yes, I have looked at that file. I have my doubts it is what the original author referred to. I was wondering if anyone familiar with legacy systems would be able to comment. – d0rmLife Mar 07 '13 at 19:54
  • +1 for `elfcore.h` header file. That is more like it...! :) Reading through it now. – d0rmLife Mar 07 '13 at 19:59
  • @d0rmLife updated the answer, you might also want to have a look at the `ptrace.h` file which can be found in your kernel header file directory as well. – Breakthrough Mar 07 '13 at 20:01
  • **Great find**, that definitely contains the sort of information I was looking for. – d0rmLife Mar 07 '13 at 20:05
  • @d0rmLife sorry, one last update - also take a look at the `calling.h` file, it also provides some very useful information. – Breakthrough Mar 07 '13 at 20:07
  • You are on a roll--I have to ask, how did you determine to look in those header files? Better at searching than me? Intimate familiarity with Linux stack allocation? – d0rmLife Mar 07 '13 at 20:08
  • 1
    @d0rmLife a bit of both. I started looking for where some of the C macros were defined, and which files *those* header files included (and so on and so fourth). I also know calling conventions are closely related with stack frames, so I thought that header might also be of some service. Also if you're inclined, you might want to look at the [x86 Assembly](http://en.wikibooks.org/wiki/X86_Assembly) and [x86 Disassembly](http://en.wikibooks.org/wiki/X86_Disassembly) books on Wikibooks, they have quite a lot of useful information. – Breakthrough Mar 07 '13 at 20:10
  • Hah--beautiful approach. Ingenious, really. I'm glad I asked. I definitely will take a look at those. I'm currently studying both of those topics! – d0rmLife Mar 07 '13 at 20:11