public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/37880] New: Documentation of option -mcmodel=medium is wrong @ 2008-10-21 8:05 agner at agner dot org 2008-10-21 14:22 ` [Bug target/37880] " jakub at gcc dot gnu dot org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: agner at agner dot org @ 2008-10-21 8:05 UTC (permalink / raw) To: gcc-bugs The documentation of option -mcmodel=medium says: -mcmodel=medium Generate code for the medium model: The program is linked in the lower 2 GB of the address space but symbols can be located anywhere in the address space. Programs can be statically or dynamically linked, but building of shared libraries are not supported with the medium model. This is misleading since the compiler still uses 32-bit addresses for data objects on Linux (and BSD?) targets. The program data are still limited to addresses < 2 GB. Dynamically allocated memory (new or malloc) can probably exceed the 2GB address limit in both the small and the medium memory model. Whatever the difference is between small and medium memory models, it is not covered by the above explanation. On Mac OS X (Darwin) targets, all addresses are above 4GB by default for both small and medium models. On Windows targets, a DLL can be loaded at addresses > 2 GB though this rarely happens. Example: ---------- code file a.cpp --------------- int * mypointer = 0; int myarray[100] = {0}; int myfunction (int x) { mypointer = myarray + 1; return myarray[x]; } ---------- end of code file a.cpp --------------- Command line: g++ -m64 -mcmodel=medium -S a.cpp gcc version: gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7) ---------- assembly output (excerpt) ----------- _Z10myfunctioni: .LFB2: pushq %rbp .LCFI0: movq %rsp, %rbp .LCFI1: movl %edi, -4(%rbp) movl $myarray+4, %eax # uses 32-bit zero-extended address here! movq %rax, mypointer(%rip) movl -4(%rbp), %eax cltq movl myarray(,%rax,4), %eax # uses 32-bit sign-extended address here! leave ret ---------- end of assembly output (excerpt) ----------- This example shows that the statement "symbols can be located anywhere in the address space" is misleading. Static symbols must be located at addresses < 2GB for the above code to work. Does the above statement apply to symbols on the stack or only to objects allocated with new or malloc? The statement is definitely wrong for Mac targets, and possibly also for Windows targets. If a correct description would be too long then there may be a link to more exact descriptions elsewhere. -- Summary: Documentation of option -mcmodel=medium is wrong Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: agner at agner dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37880 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/37880] Documentation of option -mcmodel=medium is wrong 2008-10-21 8:05 [Bug c++/37880] New: Documentation of option -mcmodel=medium is wrong agner at agner dot org @ 2008-10-21 14:22 ` jakub at gcc dot gnu dot org 2008-10-21 23:09 ` jakub at gcc dot gnu dot org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu dot org @ 2008-10-21 14:22 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from jakub at gcc dot gnu dot org 2008-10-21 14:21 ------- The documentation just documents the previous mcmodel=medium behavior. -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |target http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37880 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/37880] Documentation of option -mcmodel=medium is wrong 2008-10-21 8:05 [Bug c++/37880] New: Documentation of option -mcmodel=medium is wrong agner at agner dot org 2008-10-21 14:22 ` [Bug target/37880] " jakub at gcc dot gnu dot org @ 2008-10-21 23:09 ` jakub at gcc dot gnu dot org 2008-10-21 23:11 ` jakub at gcc dot gnu dot org 2008-11-22 8:23 ` jakub at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu dot org @ 2008-10-21 23:09 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from jakub at gcc dot gnu dot org 2008-10-21 23:08 ------- Subject: Bug 37880 Author: jakub Date: Tue Oct 21 23:07:01 2008 New Revision: 141281 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141281 Log: PR target/37880 * doc/invoke.texi: Fix spelling of -mlarge-data-threshold option. Adjust -mcmodel=medium description for 2005-07-31 changes. Modified: trunk/gcc/ChangeLog trunk/gcc/doc/invoke.texi -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37880 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/37880] Documentation of option -mcmodel=medium is wrong 2008-10-21 8:05 [Bug c++/37880] New: Documentation of option -mcmodel=medium is wrong agner at agner dot org 2008-10-21 14:22 ` [Bug target/37880] " jakub at gcc dot gnu dot org 2008-10-21 23:09 ` jakub at gcc dot gnu dot org @ 2008-10-21 23:11 ` jakub at gcc dot gnu dot org 2008-11-22 8:23 ` jakub at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu dot org @ 2008-10-21 23:11 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from jakub at gcc dot gnu dot org 2008-10-21 23:10 ------- Fixed. -- jakub at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37880 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/37880] Documentation of option -mcmodel=medium is wrong 2008-10-21 8:05 [Bug c++/37880] New: Documentation of option -mcmodel=medium is wrong agner at agner dot org ` (2 preceding siblings ...) 2008-10-21 23:11 ` jakub at gcc dot gnu dot org @ 2008-11-22 8:23 ` jakub at gcc dot gnu dot org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu dot org @ 2008-11-22 8:23 UTC (permalink / raw) To: gcc-bugs ------- Comment #4 from jakub at gcc dot gnu dot org 2008-11-22 08:22 ------- Subject: Bug 37880 Author: jakub Date: Sat Nov 22 08:21:04 2008 New Revision: 142112 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142112 Log: PR target/37880 * doc/invoke.texi: Adjust wording of -mcmodel=medium description. Modified: trunk/gcc/ChangeLog trunk/gcc/doc/invoke.texi -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37880 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-22 8:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-10-21 8:05 [Bug c++/37880] New: Documentation of option -mcmodel=medium is wrong agner at agner dot org 2008-10-21 14:22 ` [Bug target/37880] " jakub at gcc dot gnu dot org 2008-10-21 23:09 ` jakub at gcc dot gnu dot org 2008-10-21 23:11 ` jakub at gcc dot gnu dot org 2008-11-22 8:23 ` jakub at gcc dot gnu dot org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).