Hello -
I have been told that for extra efficiency we should always compile
code with frame pointer ommited (-fomit-frame-pointer), also -pipe.
What is the reason for this? Why does it make a better executable? Are
there situations where it doesn't work or isn't the best thing to do?
Also I don't understand why not always make Position Independent Code
(-fPIC)?
Thanks.
Dec 12 '07
14 1847
On 14 Dec 2007 at 18:22, Stephen Sprunk wrote:
"Brian" <tr**@nospam.co mwrote in message
news:sl******** ***********@nos pam.invalid...
>>>>I have been told that for extra efficiency we should always compile code with frame pointer ommited (-fomit-frame-pointer)
Not using a frame pointer makes an extra register available for other uses, which speeds things up on processors with few registers (in particular, on x86 processors). Using one can make debugging easier, though I think gdb can do most things without one.
Wouldn't it be better then if the frame pointer was ommited by default unless debugging (-g) is switched on?
Some debugging can be done without symbols, and it's easier with a frame
pointer.
But if you are planning to debug, why wouldn't you include symbols (-g)?
>>>also -pipe.
This gcc option just uses pipes between compiler stages instead of temporary files. It might speed up compilation a little but probably not a lot on current systems.
So why isn't this enabled by default?
Because a pipe means multiple compiler stages would be in memory and
consuming CPU at the same time. That may be fine for some systems, but it
isn't for others.
OK, but nowadays any computer will have huge CPU and RAM resources, so
why not make -pipe the default and let people turn it off if they're
compiling on a stone-age machine?
>>>>Also I don't understand why not always make Position Independent Code (-fPIC)?
Position independent code is likely to be somewhat slower on most systems, just because of extra indirections. It's needed for shared libraries.
Isn't it good to be able to relocate all code, not just library code?
Non-library code is relocated at link time; it doesn't need to be
position-independent (or relocated) at runtime.
But if it doesn't cost anything to have the extra flexibility, then why
not?
Best
Brian
Richard Tobin wrote:
Brian <tr**@nospam.co mwrote:
>>Position independent code is likely to be somewhat slower on most systems, just because of extra indirections. It's needed for shared libraries.
>Isn't it good to be able to relocate all code, not just library code?
Why? Who needs to relocate code in complete programs?
The code in compiled-but-not-linked files (.o files in unix) is
relocatable in the sense that it doesn't yet have the addresses filled
in, but that's a quite separate issue: when it's linked, a new version
is made with the addresses filled in. The code in shared libraries
needs to be runnable at different addresses without copying it (so it
can be shared).
The voice of someone who has never seen machines without relocation
registers. The innocence of youth.
--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home .att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com
"Brian" <tr**@nospam.co mwrote in message
news:sl******** ***********@nos pam.invalid...
On 14 Dec 2007 at 18:22, Stephen Sprunk wrote:
>"Brian" <tr**@nospam.co mwrote in message news:sl******* ************@no spam.invalid...
>>>>>I have been told that for extra efficiency we should always compile >code with frame pointer ommited (-fomit-frame-pointer)
Not using a frame pointer makes an extra register available for other uses, which speeds things up on processors with few registers (in particular , on x86 processors). Using one can make debugging easier, though I think gdb can do most things without one.
Wouldn't it be better then if the frame pointer was ommited by default unless debugging (-g) is switched on?
Some debugging can be done without symbols, and it's easier with a frame pointer.
But if you are planning to debug, why wouldn't you include symbols (-g)?
I'm usually not _planning_ to debug. Bugs are things that take one by
surprise, because if they weren't, one would have already fixed the problem.
When we ship products to customers, they do not contain symbols; if the code
crashes, we have to debug the code without them -- or dig up the separate
symbol files we don't ship.
Of course, when adding a new function or doing unit tests, all the
appropriate flags are set to make debugging as easy as possible, but some
always manage to hide until customers get their hands on the "finished"
product.
>>>>also -pipe.
This gcc option just uses pipes between compiler stages instead of temporary files. It might speed up compilation a little but probably not a lot on current systems.
So why isn't this enabled by default?
Because a pipe means multiple compiler stages would be in memory and consuming CPU at the same time. That may be fine for some systems, but it isn't for others.
OK, but nowadays any computer will have huge CPU and RAM resources, so
why not make -pipe the default and let people turn it off if they're
compiling on a stone-age machine?
*shrug* Take that up with the GCC folks.
>>>>>Also I don't understand why not always make Position Independent Code >(-fPIC)?
Position independent code is likely to be somewhat slower on most systems, just because of extra indirections. It's needed for shared libraries.
Isn't it good to be able to relocate all code, not just library code?
Non-library code is relocated at link time; it doesn't need to be position-independent (or relocated) at runtime.
But if it doesn't cost anything to have the extra flexibility, then why
not?
On most systems I'm familiar with, PIC code is larger and slower. If you
don't need to suffer that penalty, you don't turn it on.
On the systems where there is no penalty for PIC code, it's on by default
(IIRC).
S
--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
On 14 Dec, 18:50, rich...@cogsci. ed.ac.uk (Richard Tobin) wrote:
In article <slrnfm5g26.hn7 .nos...@nospam. invalid>,
Brian <t...@nospam.co mwrote:
Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.
Isn't it good to be able to relocate all code, not just library code?
Why? Who needs to relocate code in complete programs?
machines with pageing but without virtual memory.
Old Macs needed to relocate code on-the-fly.
Didn't Crays not have virtual memory?
The code in compiled-but-not-linked files (.o files in unix) is
relocatable in the sense that it doesn't yet have the addresses filled
in, but that's a quite separate issue: when it's linked, a new version
is made with the addresses filled in. The code in shared libraries
needs to be runnable at different addresses without copying it (so it
can be shared).
--
Nick Keighley
In article <fa************ *************** *******@b1g2000 pra.googlegroup s.com>,
Nick Keighley <ni************ ******@hotmail. comwrote:
>Position independent code is likely to be somewhat slower on most systems, just because of extra indirections. It's needed for shared libraries.
>Isn't it good to be able to relocate all code, not just library code?
>Why? Who needs to relocate code in complete programs?
>machines with pageing but without virtual memory. Old Macs needed to relocate code on-the-fly. Didn't Crays not have virtual memory?
In other words, almost nobody. Unless you have peculiar requirements,
there's no advantage to position independent code outside libraries.
-- Richard
--
:wq This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil |
last post by:
Supposedly, the code below should assign the correct value to the
'url' variable.
But all I get is a blank 'main' Frame with apparently nowhere to go
when I
click
on the link in the 'menu' Frame..
Worst(yesyes!!)
1 - Explorer 6 : clicking a link in the 'menu' frame simple reopens an
instance of the FRAMESET, syntax error msg.
2 - Netscape 7.1 : clicking a link in the 'menu' frame simple reopens
|
by: Tim Streater |
last post by:
I have this arrangement of frames:
<html><head><script type="text/javascript"></script></head>
<frameset rows="100,*">
<frameset cols="135,*,165">
<frame name="logo" src="some.html" scrolling="No">
<frame name="title" src="someother.html" scrolling="No">
<frame name="nav" src="yetmore.html" scrolling="No">
</frameset>
|
by: asm |
last post by:
Hello all, I need your help on this problem.
I wrote a little program as follows. (BTW, I worked on a new dell
latitude, runing Linux kernel 2.4.19, i686).
Program was compiled with gcc 3.2
void foo() {
char t;
strcpy(t, "012345678901234567890123456789012345678");
|
by: anonymous |
last post by:
Thanks your reply.
The article I read is from
www.hakin9.org/en/attachments/stackoverflow_en.pdf.
And you're right. I don't know it very clearly. And that's why I want
to understand it; for it's useful to help me to solve some basic
problem which I may not perceive before.
I appreciate your help,
sincerely.
|
by: Søren M. Olesen |
last post by:
How do I manipulate a control in one frame from another frame ??
I've tried something like:
Class1
TextBox.Text="Text1"
Session("TextBox")=TextBox1
Class2
| |
by: AndrewV |
last post by:
I have an html page that has 2 frames ("input" and "result"). In the "input"
frame, there is a text box and a button. User enters an id in the text box,
then click on the button. In the click event, I would like to call an
asp.net page, and passing in the text box value as a query string parameter
(http://mysite/mypage.aspx?id=x) and display the result in the "result"
frame. I couldn't find a way to do it. Please give me some pointer on how...
|
by: Martin Chen |
last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main
frame. The contents frame has a menu bar written with with javascript (in
the context of a table). In IE6.1 everything works fine as it also does in
firefox if I call the contents frame directly (i.e. outside of its
frameset). However, if I call my main page (index.html) which invokes the
frame set, the contents frame javascript menubar onmouseover function...
|
by: bekz |
last post by:
Hi All,
I have written exploits for binaries with fixed stack frame pointer.
But now a days most of the compliers generates instrutions with random
stack frame pointer. And with injecting Windows API function addresses,
how can we inject the argument address for foreign exe?
How can I go about writing exploits for such codes?
Note: Most of the codes that I would like to write exploits is having
|
by: code break |
last post by:
Hi all,
What is the difference between stack pointer and frame pointer ?
Any suggestions are welcome ,,,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |