mirror of
https://github.com/mirror/tinycc.git
synced 2026-08-24 11:33:28 +08:00
Compare commits
44 Commits
release_0_
...
release_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44cea6aee9 | ||
|
|
77a19bf50e | ||
|
|
b7f12dfbdf | ||
|
|
9890ea1233 | ||
|
|
feed3262c9 | ||
|
|
bef8703f77 | ||
|
|
46169b92d9 | ||
|
|
d369a77647 | ||
|
|
c5ce5eaeda | ||
|
|
9c1106d854 | ||
|
|
f8d0241764 | ||
|
|
c5959b77b4 | ||
|
|
7b940fcb1b | ||
|
|
21d2d99bdc | ||
|
|
277e01cd64 | ||
|
|
9d95be78c8 | ||
|
|
370f5e571c | ||
|
|
d0476a0e2e | ||
|
|
4e6edcdcdd | ||
|
|
98713a6be3 | ||
|
|
fe3b68b087 | ||
|
|
770ef5ed1f | ||
|
|
7b05ed6b81 | ||
|
|
8f5e44a439 | ||
|
|
813acdc691 | ||
|
|
638e666c42 | ||
|
|
e58bda52cd | ||
|
|
f0d5a74bcd | ||
|
|
6cdf6f88d7 | ||
|
|
5908725ad5 | ||
|
|
edbfa7715f | ||
|
|
c4e6b2e9be | ||
|
|
71f119fe25 | ||
|
|
68c800981e | ||
|
|
a901c5f204 | ||
|
|
2b64f2f570 | ||
|
|
7828683e60 | ||
|
|
60efcfe27c | ||
|
|
356fa0c3bb | ||
|
|
9791bfaf48 | ||
|
|
0eef235475 | ||
|
|
410fc57ba0 | ||
|
|
066d5e7a84 | ||
|
|
214ccccea7 |
24
.cvsignore
24
.cvsignore
@@ -1,40 +1,26 @@
|
||||
tcc_g
|
||||
tcc
|
||||
tc.c.1
|
||||
t.c
|
||||
tc2.c
|
||||
p3.s
|
||||
ex3
|
||||
ex1.c
|
||||
ex2.c
|
||||
otcc1.c
|
||||
doc
|
||||
tc3s.c
|
||||
p3.c
|
||||
tc1.c
|
||||
error.c
|
||||
p1.s
|
||||
t.s
|
||||
userlist.txt
|
||||
tcc1.c
|
||||
i386-gen1.c
|
||||
ex4.c
|
||||
test.out2
|
||||
test.out3
|
||||
web.sh
|
||||
ex3.c
|
||||
memdebug.c
|
||||
bench
|
||||
ex5.c
|
||||
tcc-newparse.c
|
||||
COPYING
|
||||
p1.c
|
||||
Makefile.uClibc
|
||||
boundtest
|
||||
p4.c
|
||||
p5.c
|
||||
prog.ref
|
||||
contacts.txt
|
||||
test.ref
|
||||
a.c
|
||||
p3
|
||||
@@ -51,11 +37,15 @@ linux.tcc
|
||||
wintest.c
|
||||
ldtest
|
||||
libtcc_test
|
||||
p2.il
|
||||
short.prof
|
||||
tccp.c
|
||||
instr.S
|
||||
p.c
|
||||
p2.c
|
||||
tcctest[1234]
|
||||
test[1234].out
|
||||
.gdb_history
|
||||
tcc.1
|
||||
tcc.pod
|
||||
config.h
|
||||
config.mak
|
||||
config.texi
|
||||
gcctestsuite.sh
|
||||
|
||||
504
COPYING
Normal file
504
COPYING
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
26
Changelog
26
Changelog
@@ -1,3 +1,29 @@
|
||||
version 0.9.20:
|
||||
|
||||
- added '-w' option
|
||||
- added '.gnu.linkonce' ELF sections support
|
||||
- fixed libc linking when running in memory (avoid 'stat' function
|
||||
errors).
|
||||
- extended '-run' option to be able to give several arguments to a C
|
||||
script.
|
||||
|
||||
version 0.9.19:
|
||||
|
||||
- "alacarte" linking (Dave Long)
|
||||
- simpler function call
|
||||
- more strict type checks
|
||||
- added 'const' and 'volatile' support and associated warnings
|
||||
- added -Werror, -Wunsupported, -Wwrite-strings, -Wall.
|
||||
- added __builtin_types_compatible_p() and __builtin_constant_p()
|
||||
- chars support in assembler (Dave Long)
|
||||
- .string, .globl, .section, .text, .data and .bss asm directive
|
||||
support (Dave Long)
|
||||
- man page generated from tcc-doc.texi
|
||||
- fixed macro argument substitution
|
||||
- fixed zero argument macro parsing
|
||||
- changed license to LGPL
|
||||
- added -rdynamic option support
|
||||
|
||||
version 0.9.18:
|
||||
|
||||
- header fix (time.h)
|
||||
|
||||
19
Makefile
19
Makefile
@@ -21,7 +21,7 @@ INSTALL=install
|
||||
# run local version of tcc with local libraries and includes
|
||||
TCC=./tcc -B. -I.
|
||||
|
||||
all: tcc libtcc1.o bcheck.o tcc-doc.html libtcc.a libtcc_test
|
||||
all: tcc libtcc1.a bcheck.o tcc-doc.html tcc.1 libtcc.a libtcc_test
|
||||
|
||||
Makefile: config.mak
|
||||
|
||||
@@ -118,24 +118,27 @@ tcc: tcc_g Makefile
|
||||
libtcc1.o: libtcc1.c
|
||||
$(CC) -O2 -Wall -c -o $@ $<
|
||||
|
||||
libtcc1.a: libtcc1.o
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
bcheck.o: bcheck.c
|
||||
$(CC) -O2 -Wall -c -o $@ $<
|
||||
|
||||
install: tcc_install libinstall
|
||||
|
||||
tcc_install: tcc libtcc1.o bcheck.o
|
||||
tcc_install: tcc tcc.1 libtcc1.a bcheck.o
|
||||
$(INSTALL) -m755 tcc $(bindir)
|
||||
$(INSTALL) tcc.1 $(mandir)/man1
|
||||
mkdir -p $(libdir)/tcc
|
||||
mkdir -p $(libdir)/tcc/include
|
||||
$(INSTALL) -m644 libtcc1.o bcheck.o $(libdir)/tcc
|
||||
$(INSTALL) -m644 libtcc1.a bcheck.o $(libdir)/tcc
|
||||
$(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
|
||||
tcclib.h $(libdir)/tcc/include
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
|
||||
core gmon.out test.out test.ref a.out tcc_p \
|
||||
*.exe tcc-doc.html libtcc.a libtcc_test \
|
||||
*.exe tcc-doc.html tcc.pod tcc.1 libtcc.a libtcc_test \
|
||||
tcctest[1234] test[1234].out
|
||||
|
||||
distclean: clean
|
||||
@@ -201,10 +204,14 @@ cache: tcc_g
|
||||
cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
|
||||
vg_annotate tcc.c > /tmp/linpack.cache.log
|
||||
|
||||
# documentation
|
||||
# documentation and man page
|
||||
tcc-doc.html: tcc-doc.texi
|
||||
texi2html -monolithic -number $<
|
||||
|
||||
tcc.1: tcc-doc.texi
|
||||
./texi2pod.pl $< tcc.pod
|
||||
pod2man --section=1 --center=" " --release=" " tcc.pod > $@
|
||||
|
||||
FILES= Makefile Makefile.uClibc configure VERSION \
|
||||
README TODO COPYING \
|
||||
Changelog tcc-doc.texi tcc-doc.html \
|
||||
@@ -215,7 +222,7 @@ FILES= Makefile Makefile.uClibc configure VERSION \
|
||||
stddef.h stdarg.h stdbool.h float.h varargs.h \
|
||||
tcclib.h libtcc.h libtcc_test.c \
|
||||
ex1.c ex2.c ex3.c ex4.c ex5.c \
|
||||
tcctest.c boundtest.c gcctestsuite.sh
|
||||
tcctest.c boundtest.c gcctestsuite.sh texi2pod.pl
|
||||
|
||||
FILE=tcc-$(VERSION)
|
||||
|
||||
|
||||
9
README
9
README
@@ -50,7 +50,7 @@ The include file <tcclib.h> can be used if you want a small basic libc
|
||||
include support (especially useful for floppy disks). Of course, you
|
||||
can also use standard headers, although they are slower to compile.
|
||||
|
||||
You can begin your C script with '#!/usr/local/bin/tcc' on the first
|
||||
You can begin your C script with '#!/usr/local/bin/tcc -run' on the first
|
||||
line and set its execute bits (chmod a+x your_script). Then, you can
|
||||
launch the C code as a shell or perl script :-) The command line
|
||||
arguments are put in 'argc' and 'argv' of the main functions, as in
|
||||
@@ -84,10 +84,7 @@ Please read tcc-doc.html to have all the features of TCC.
|
||||
License:
|
||||
-------
|
||||
|
||||
TCC is distributed under the GNU General Public License (see COPYING
|
||||
file).
|
||||
|
||||
License may be changed to LGPL or X11 style, so I would prefer that
|
||||
you indicate in submitted patches that you accept such a change.
|
||||
TCC is distributed under the GNU Lesser General Public License (see
|
||||
COPYING file).
|
||||
|
||||
Fabrice Bellard.
|
||||
|
||||
23
TODO
23
TODO
@@ -1,5 +1,15 @@
|
||||
TODO list:
|
||||
|
||||
- cast bug (Peter Wang)
|
||||
- define incomplete type if defined several times (Peter Wang).
|
||||
- long long constant evaluation
|
||||
- configure --cc=tcc (still one bug in libtcc1.c)
|
||||
- disable-asm and disable-bcheck options
|
||||
- test binutils/gcc compile
|
||||
- add alloca(), __builtin_expect()
|
||||
- gcc '-E' option.
|
||||
- optimize VT_LOCAL + const
|
||||
- tci patch + argument.
|
||||
- '-b' bug.
|
||||
- atexit (Nigel Horne)
|
||||
- see -lxxx bug (Michael Charity).
|
||||
@@ -8,31 +18,22 @@ TODO list:
|
||||
- precise behaviour of typeof with arrays ? (__put_user macro)
|
||||
- #include_next support for /usr/include/limits ?
|
||||
but should suffice for most cases)
|
||||
- handle '? x, y : z' in reversed function arguments or unsized
|
||||
variable initialization (',' is considered incorrectly as separator
|
||||
in preparser) : change func argument code generator ?
|
||||
- handle '? x, y : z' in unsized variable initialization (',' is
|
||||
considered incorrectly as separator in preparser)
|
||||
- function pointers/lvalues in ? : (linux kernel net/core/dev.c)
|
||||
- transform functions to function pointers in function parameters (net/ipv4/ip_output.c)
|
||||
- fix function pointer type display
|
||||
- fix bound exit on RedHat 7.3
|
||||
- fix static link on RedHat 7.3
|
||||
- check lcc test suite -> fix bitfield binary operations
|
||||
- check section alignment in C
|
||||
- fix invalid cast in comparison 'if (v == (int8_t)v)'
|
||||
- packed attribute
|
||||
- look at patches from Scott Lafferty
|
||||
- look at bugs from Jason Petrasko.
|
||||
- support link once trick (gcc 3.2 / glibc compilation issue)
|
||||
- finish varargs.h support (gcc 3.2 testsuite issue)
|
||||
- add alloca()
|
||||
- fix static functions declared inside block
|
||||
- C99: add variable size arrays (gcc 3.2 testsuite issue)
|
||||
- C99: add complex types (gcc 3.2 testsuite issue)
|
||||
- postfix compound literals (see 20010124-1.c)
|
||||
- fix multiple unions init
|
||||
- test includes in libtcc_test.
|
||||
- look at GCC 3.2 compatibility problems.
|
||||
- add option for auto run
|
||||
- setjmp is not supported properly in bound checking.
|
||||
- better local variables handling (needed for other targets)
|
||||
- fix bound check code with '&' on local variables (currently done
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
.align 16, 0x90
|
||||
.skip 3
|
||||
.skip 15, 0x90
|
||||
.string "hello\0world"
|
||||
|
||||
/* some label tests */
|
||||
|
||||
|
||||
8
ex1.c
Executable file
8
ex1.c
Executable file
@@ -0,0 +1,8 @@
|
||||
#! /usr/local/bin/tcc -run
|
||||
#include <tcclib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
||||
97
ex2.c
Normal file
97
ex2.c
Normal file
@@ -0,0 +1,97 @@
|
||||
#include "tcclib.h"
|
||||
|
||||
#define N 20
|
||||
|
||||
int nb_num;
|
||||
int tab[N];
|
||||
int stack_ptr;
|
||||
int stack_op[N];
|
||||
int stack_res[60];
|
||||
int result;
|
||||
|
||||
int find(int n, int i1, int a, int b, int op)
|
||||
{
|
||||
int i, j;
|
||||
int c;
|
||||
|
||||
if (stack_ptr >= 0) {
|
||||
stack_res[3*stack_ptr] = a;
|
||||
stack_op[stack_ptr] = op;
|
||||
stack_res[3*stack_ptr+1] = b;
|
||||
stack_res[3*stack_ptr+2] = n;
|
||||
if (n == result)
|
||||
return 1;
|
||||
tab[i1] = n;
|
||||
}
|
||||
|
||||
for(i=0;i<nb_num;i++) {
|
||||
for(j=i+1;j<nb_num;j++) {
|
||||
a = tab[i];
|
||||
b = tab[j];
|
||||
if (a != 0 && b != 0) {
|
||||
|
||||
tab[j] = 0;
|
||||
stack_ptr++;
|
||||
|
||||
if (find(a + b, i, a, b, '+'))
|
||||
return 1;
|
||||
if (find(a - b, i, a, b, '-'))
|
||||
return 1;
|
||||
if (find(b - a, i, b, a, '-'))
|
||||
return 1;
|
||||
if (find(a * b, i, a, b, '*'))
|
||||
return 1;
|
||||
if (b != 0) {
|
||||
c = a / b;
|
||||
if (find(c, i, a, b, '/'))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a != 0) {
|
||||
c = b / a;
|
||||
if (find(c, i, b, a, '/'))
|
||||
return 1;
|
||||
}
|
||||
|
||||
stack_ptr--;
|
||||
tab[i] = a;
|
||||
tab[j] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, res, p;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s: result numbers...\n"
|
||||
"Try to find result from numbers with the 4 basic operations.\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
p = 1;
|
||||
result = atoi(argv[p]);
|
||||
printf("result=%d\n", result);
|
||||
nb_num = 0;
|
||||
for(i=p+1;i<argc;i++) {
|
||||
tab[nb_num++] = atoi(argv[i]);
|
||||
}
|
||||
|
||||
stack_ptr = -1;
|
||||
res = find(0, 0, 0, 0, ' ');
|
||||
if (res) {
|
||||
for(i=0;i<=stack_ptr;i++) {
|
||||
printf("%d %c %d = %d\n",
|
||||
stack_res[3*i], stack_op[i],
|
||||
stack_res[3*i+1], stack_res[3*i+2]);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
printf("Impossible\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
23
ex3.c
Normal file
23
ex3.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <tcclib.h>
|
||||
|
||||
int fib(n)
|
||||
{
|
||||
if (n <= 2)
|
||||
return 1;
|
||||
else
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
if (argc < 2) {
|
||||
printf("usage: fib n\n"
|
||||
"Compute nth Fibonacci number\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = atoi(argv[1]);
|
||||
printf("fib(%d) = %d\n", n, fib(n, 2));
|
||||
return 0;
|
||||
}
|
||||
25
ex4.c
Executable file
25
ex4.c
Executable file
@@ -0,0 +1,25 @@
|
||||
#!./tcc -run -L/usr/X11R6/lib -lX11
|
||||
#include <stdlib.h>
|
||||
/* Yes, TCC can use X11 too ! */
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Display *display;
|
||||
Screen *screen;
|
||||
|
||||
display = XOpenDisplay("");
|
||||
if (!display) {
|
||||
fprintf(stderr, "Could not open X11 display\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("X11 display opened.\n");
|
||||
screen = XScreenOfDisplay(display, 0);
|
||||
printf("width = %d\nheight = %d\ndepth = %d\n",
|
||||
screen->width,
|
||||
screen->height,
|
||||
screen->root_depth);
|
||||
XCloseDisplay(display);
|
||||
return 0;
|
||||
}
|
||||
8
ex5.c
Normal file
8
ex5.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
||||
33
gcctestsuite.sh
Executable file
33
gcctestsuite.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
TESTSUITE_PATH=$HOME/gcc/gcc-3.2/gcc/testsuite/gcc.c-torture
|
||||
TCC="./tcc -B. -I. -DNO_TRAMPOLINES"
|
||||
rm -f tcc.sum tcc.log
|
||||
nb_failed="0"
|
||||
|
||||
for src in $TESTSUITE_PATH/compile/*.c ; do
|
||||
echo $TCC -o /tmp/test.o -c $src
|
||||
$TCC -o /tmp/test.o -c $src >> tcc.log 2>&1
|
||||
if [ "$?" == "0" ] ; then
|
||||
result="PASS"
|
||||
else
|
||||
result="FAIL"
|
||||
nb_failed=$[ $nb_failed + 1 ]
|
||||
fi
|
||||
echo "$result: $src" >> tcc.sum
|
||||
done
|
||||
|
||||
for src in $TESTSUITE_PATH/execute/*.c ; do
|
||||
echo $TCC $src
|
||||
$TCC $src >> tcc.log 2>&1
|
||||
if [ "$?" == "0" ] ; then
|
||||
result="PASS"
|
||||
else
|
||||
result="FAIL"
|
||||
nb_failed=$[ $nb_failed + 1 ]
|
||||
fi
|
||||
echo "$result: $src" >> tcc.sum
|
||||
done
|
||||
|
||||
echo "$nb_failed test(s) failed." >> tcc.sum
|
||||
echo "$nb_failed test(s) failed."
|
||||
36
i386-asm.c
36
i386-asm.c
@@ -3,19 +3,19 @@
|
||||
*
|
||||
* Copyright (c) 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define MAX_OPERANDS 3
|
||||
@@ -745,6 +745,13 @@ static inline int constraint_priority(const char *str)
|
||||
return priority;
|
||||
}
|
||||
|
||||
static const char *skip_constraint_modifiers(const char *p)
|
||||
{
|
||||
while (*p == '=' || *p == '&' || *p == '+' || *p == '%')
|
||||
p++;
|
||||
return p;
|
||||
}
|
||||
|
||||
static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
ASMOperand *operands,
|
||||
int nb_operands1, int nb_outputs,
|
||||
@@ -772,6 +779,7 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
str = op->constraint;
|
||||
op->ref_index = -1;
|
||||
op->reg = -1;
|
||||
str = skip_constraint_modifiers(str);
|
||||
if (!is_output && (isnum(*str) || *str == '[')) {
|
||||
/* this is a reference to another constraint */
|
||||
k = find_constraint(operands, nb_operands1, str, NULL);
|
||||
@@ -780,9 +788,8 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
j, str);
|
||||
op->ref_index = k;
|
||||
str = operands[k].constraint;
|
||||
str = skip_constraint_modifiers(str);
|
||||
}
|
||||
while (*str == '=' || *str == '&' || *str == '+')
|
||||
str++;
|
||||
op->priority = constraint_priority(str);
|
||||
}
|
||||
|
||||
@@ -815,8 +822,7 @@ static void asm_compute_constraints(uint8_t *regs_allocated,
|
||||
str = operands[op->ref_index].constraint;
|
||||
}
|
||||
|
||||
while (*str == '=' || *str == '&' || *str == '+')
|
||||
str++;
|
||||
str = skip_constraint_modifiers(str);
|
||||
try_next:
|
||||
c = *str++;
|
||||
switch(c) {
|
||||
|
||||
152
i386-gen.c
152
i386-gen.c
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
* X86 code generator for TCC
|
||||
*
|
||||
* Copyright (c) 2001, 2002 Fabrice Bellard
|
||||
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* number of available registers */
|
||||
@@ -73,12 +73,6 @@ int reg_classes[NB_REGS] = {
|
||||
/* relocation type for 32 bit data relocation */
|
||||
#define R_DATA_32 R_386_32
|
||||
|
||||
/* function call context */
|
||||
typedef struct GFuncContext {
|
||||
int args_size;
|
||||
int func_call; /* func call type (FUNC_STDCALL or FUNC_CDECL) */
|
||||
} GFuncContext;
|
||||
|
||||
/******************************************************/
|
||||
|
||||
static unsigned long func_sub_sp_offset;
|
||||
@@ -282,65 +276,6 @@ void store(int r, SValue *v)
|
||||
}
|
||||
}
|
||||
|
||||
/* start function call and return function call context */
|
||||
void gfunc_start(GFuncContext *c, int func_call)
|
||||
{
|
||||
c->args_size = 0;
|
||||
c->func_call = func_call;
|
||||
}
|
||||
|
||||
/* push function parameter which is in (vtop->t, vtop->c). Stack entry
|
||||
is then popped. */
|
||||
void gfunc_param(GFuncContext *c)
|
||||
{
|
||||
int size, align, r;
|
||||
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
|
||||
size = type_size(&vtop->type, &align);
|
||||
/* align to stack align size */
|
||||
size = (size + 3) & ~3;
|
||||
/* allocate the necessary size on stack */
|
||||
oad(0xec81, size); /* sub $xxx, %esp */
|
||||
/* generate structure store */
|
||||
r = get_reg(RC_INT);
|
||||
o(0x89); /* mov %esp, r */
|
||||
o(0xe0 + r);
|
||||
vset(&vtop->type, r | VT_LVAL, 0);
|
||||
vswap();
|
||||
vstore();
|
||||
c->args_size += size;
|
||||
} else if (is_float(vtop->type.t)) {
|
||||
gv(RC_FLOAT); /* only one float register */
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_FLOAT)
|
||||
size = 4;
|
||||
else if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
|
||||
size = 8;
|
||||
else
|
||||
size = 12;
|
||||
oad(0xec81, size); /* sub $xxx, %esp */
|
||||
if (size == 12)
|
||||
o(0x7cdb);
|
||||
else
|
||||
o(0x5cd9 + size - 4); /* fstp[s|l] 0(%esp) */
|
||||
g(0x24);
|
||||
g(0x00);
|
||||
c->args_size += size;
|
||||
} else {
|
||||
/* simple type (currently always same size) */
|
||||
/* XXX: implicit cast ? */
|
||||
r = gv(RC_INT);
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
|
||||
size = 8;
|
||||
o(0x50 + vtop->r2); /* push r */
|
||||
} else {
|
||||
size = 4;
|
||||
}
|
||||
o(0x50 + r); /* push r */
|
||||
c->args_size += size;
|
||||
}
|
||||
vtop--;
|
||||
}
|
||||
|
||||
static void gadd_sp(int val)
|
||||
{
|
||||
if (val == (char)val) {
|
||||
@@ -375,13 +310,66 @@ static void gcall_or_jmp(int is_jmp)
|
||||
}
|
||||
}
|
||||
|
||||
/* generate function call with address in (vtop->t, vtop->c) and free function
|
||||
context. Stack entry is popped */
|
||||
void gfunc_call(GFuncContext *c)
|
||||
/* Generate function call. The function address is pushed first, then
|
||||
all the parameters in call order. This functions pops all the
|
||||
parameters and the function address. */
|
||||
void gfunc_call(int nb_args)
|
||||
{
|
||||
int size, align, r, args_size, i;
|
||||
Sym *func_sym;
|
||||
|
||||
args_size = 0;
|
||||
for(i = 0;i < nb_args; i++) {
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
|
||||
size = type_size(&vtop->type, &align);
|
||||
/* align to stack align size */
|
||||
size = (size + 3) & ~3;
|
||||
/* allocate the necessary size on stack */
|
||||
oad(0xec81, size); /* sub $xxx, %esp */
|
||||
/* generate structure store */
|
||||
r = get_reg(RC_INT);
|
||||
o(0x89); /* mov %esp, r */
|
||||
o(0xe0 + r);
|
||||
vset(&vtop->type, r | VT_LVAL, 0);
|
||||
vswap();
|
||||
vstore();
|
||||
args_size += size;
|
||||
} else if (is_float(vtop->type.t)) {
|
||||
gv(RC_FLOAT); /* only one float register */
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_FLOAT)
|
||||
size = 4;
|
||||
else if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
|
||||
size = 8;
|
||||
else
|
||||
size = 12;
|
||||
oad(0xec81, size); /* sub $xxx, %esp */
|
||||
if (size == 12)
|
||||
o(0x7cdb);
|
||||
else
|
||||
o(0x5cd9 + size - 4); /* fstp[s|l] 0(%esp) */
|
||||
g(0x24);
|
||||
g(0x00);
|
||||
args_size += size;
|
||||
} else {
|
||||
/* simple type (currently always same size) */
|
||||
/* XXX: implicit cast ? */
|
||||
r = gv(RC_INT);
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
|
||||
size = 8;
|
||||
o(0x50 + vtop->r2); /* push r */
|
||||
} else {
|
||||
size = 4;
|
||||
}
|
||||
o(0x50 + r); /* push r */
|
||||
args_size += size;
|
||||
}
|
||||
vtop--;
|
||||
}
|
||||
save_regs(0); /* save used temporary registers */
|
||||
func_sym = vtop->type.ref;
|
||||
gcall_or_jmp(0);
|
||||
if (c->args_size && c->func_call == FUNC_CDECL)
|
||||
gadd_sp(c->args_size);
|
||||
if (args_size && func_sym->r == FUNC_CDECL)
|
||||
gadd_sp(args_size);
|
||||
vtop--;
|
||||
}
|
||||
|
||||
|
||||
15
libtcc.h
15
libtcc.h
@@ -1,6 +1,10 @@
|
||||
#ifndef LIBTCC_H
|
||||
#define LIBTCC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct TCCState;
|
||||
|
||||
typedef struct TCCState TCCState;
|
||||
@@ -18,6 +22,9 @@ void tcc_enable_debug(TCCState *s);
|
||||
void tcc_set_error_func(TCCState *s, void *error_opaque,
|
||||
void (*error_func)(void *opaque, const char *msg));
|
||||
|
||||
/* set/reset a warning */
|
||||
int tcc_set_warning(TCCState *s, const char *warning_name, int value);
|
||||
|
||||
/*****************************/
|
||||
/* preprocessor */
|
||||
|
||||
@@ -76,7 +83,11 @@ int tcc_run(TCCState *s, int argc, char **argv);
|
||||
non zero if link error. */
|
||||
int tcc_relocate(TCCState *s);
|
||||
|
||||
/* return symbol value or error */
|
||||
void *tcc_get_symbol(TCCState *s, const char *name);
|
||||
/* return symbol value. return 0 if OK, -1 if symbol not found */
|
||||
int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
39
libtcc1.c
39
libtcc1.c
@@ -421,19 +421,58 @@ unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
long long __sardi3(long long a, int b)
|
||||
{
|
||||
#ifdef __TINYC__
|
||||
DWunion u;
|
||||
u.ll = a;
|
||||
if (b >= 32) {
|
||||
u.s.low = u.s.high >> (b - 32);
|
||||
u.s.high = u.s.high >> 31;
|
||||
} else if (b != 0) {
|
||||
u.s.low = ((unsigned)u.s.low >> b) | (u.s.high << (32 - b));
|
||||
u.s.high = u.s.high >> b;
|
||||
}
|
||||
return u.ll;
|
||||
#else
|
||||
return a >> b;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
unsigned long long __shrdi3(unsigned long long a, int b)
|
||||
{
|
||||
#ifdef __TINYC__
|
||||
DWunion u;
|
||||
u.ll = a;
|
||||
if (b >= 32) {
|
||||
u.s.low = (unsigned)u.s.high >> (b - 32);
|
||||
u.s.high = 0;
|
||||
} else if (b != 0) {
|
||||
u.s.low = ((unsigned)u.s.low >> b) | (u.s.high << (32 - b));
|
||||
u.s.high = (unsigned)u.s.high >> b;
|
||||
}
|
||||
return u.ll;
|
||||
#else
|
||||
return a >> b;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* XXX: fix tcc's code generator to do this instead */
|
||||
long long __shldi3(long long a, int b)
|
||||
{
|
||||
#ifdef __TINYC__
|
||||
DWunion u;
|
||||
u.ll = a;
|
||||
if (b >= 32) {
|
||||
u.s.high = (unsigned)u.s.low << (b - 32);
|
||||
u.s.low = 0;
|
||||
} else if (b != 0) {
|
||||
u.s.high = ((unsigned)u.s.high << b) | (u.s.low >> (32 - b));
|
||||
u.s.low = (unsigned)u.s.low << b;
|
||||
}
|
||||
return u.ll;
|
||||
#else
|
||||
return a << b;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__i386__)
|
||||
|
||||
@@ -35,7 +35,8 @@ int main(int argc, char **argv)
|
||||
{
|
||||
TCCState *s;
|
||||
int (*func)(int);
|
||||
|
||||
unsigned long val;
|
||||
|
||||
s = tcc_new();
|
||||
if (!s) {
|
||||
fprintf(stderr, "Could not create tcc state\n");
|
||||
@@ -54,8 +55,9 @@ int main(int argc, char **argv)
|
||||
|
||||
tcc_relocate(s);
|
||||
|
||||
func = tcc_get_symbol(s, "foo");
|
||||
|
||||
tcc_get_symbol(s, &val, "foo");
|
||||
func = (void *)val;
|
||||
|
||||
func(32);
|
||||
|
||||
tcc_delete(s);
|
||||
|
||||
115
tcc-doc.texi
115
tcc-doc.texi
@@ -66,12 +66,13 @@ generation (@pxref{Libtcc}).
|
||||
@section Quick start
|
||||
|
||||
@example
|
||||
usage: tcc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym]
|
||||
[-g] [-b] [-bt N] [-Ldir] [-llib] [-shared] [-static]
|
||||
[infile1 infile2...] [-run infile args...]
|
||||
@c man begin SYNOPSIS
|
||||
usage: tcc [options] [@var{infile1} @var{infile2}@dots{}] [@option{-run} @var{infile} @var{args}@dots{}]
|
||||
@c man end
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
@c man begin DESCRIPTION
|
||||
TCC options are a very much like gcc options. The main difference is that TCC
|
||||
can also execute directly the resulting program and give it runtime
|
||||
arguments.
|
||||
@@ -120,7 +121,7 @@ TCC can be invoked from @emph{scripts}, just as shell scripts. You just
|
||||
need to add @code{#!/usr/local/bin/tcc -run} at the start of your C source:
|
||||
|
||||
@example
|
||||
#!/usr/local/bin/tcc
|
||||
#!/usr/local/bin/tcc -run
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
@@ -129,11 +130,13 @@ int main()
|
||||
return 0;
|
||||
@}
|
||||
@end example
|
||||
@c man end
|
||||
|
||||
@section Option summary
|
||||
|
||||
General Options:
|
||||
|
||||
@c man begin OPTIONS
|
||||
@table @option
|
||||
@item -v
|
||||
Display current TCC version.
|
||||
@@ -151,8 +154,28 @@ Set the path where the tcc internal libraries can be found (default is
|
||||
@item -bench
|
||||
Output compilation statistics.
|
||||
|
||||
@item -run
|
||||
Run compiled source.
|
||||
@item -run source [args...]
|
||||
|
||||
Compile file @var{source} and run it with the command line arguments
|
||||
@var{args}. In order to be able to give more than one argument to a
|
||||
script, several TCC options can be given @emph{after} the
|
||||
@option{-run} option, separated by spaces. Example:
|
||||
|
||||
@example
|
||||
tcc "-run -L/usr/X11R6/lib -lX11" ex4.c
|
||||
@end example
|
||||
|
||||
In a script, it gives the following header:
|
||||
|
||||
@example
|
||||
#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv)
|
||||
@{
|
||||
...
|
||||
@}
|
||||
@end example
|
||||
|
||||
@end table
|
||||
|
||||
Preprocessor options:
|
||||
@@ -176,6 +199,34 @@ also be defined: @option{-DF(a)=a+1}
|
||||
Undefine preprocessor symbol @samp{sym}.
|
||||
@end table
|
||||
|
||||
Warning options:
|
||||
|
||||
@table @option
|
||||
@item -w
|
||||
Disable all warnings.
|
||||
|
||||
@end table
|
||||
|
||||
Note: each of the following warning options has a negative form beginning with
|
||||
@option{-Wno-}.
|
||||
|
||||
@table @option
|
||||
@item -Wunsupported
|
||||
Warn about unsupported GCC features that are ignored by TCC.
|
||||
|
||||
@item -Wwrite-strings
|
||||
Make string constants being of type @code{const char *} intead of @code{char
|
||||
*}.
|
||||
|
||||
@item -Werror
|
||||
Abort compilation if warnings are issued.
|
||||
|
||||
@item -Wall
|
||||
Activate all warnings, except @option{-Werror}, @option{-Wunusupported} and
|
||||
@option{-Wwrite-strings} (currently not useful).
|
||||
|
||||
@end table
|
||||
|
||||
Linker options:
|
||||
|
||||
@table @option
|
||||
@@ -196,6 +247,10 @@ must also be given).
|
||||
Generate a statically linked executable (default is a shared linked
|
||||
executable) (@option{-o} option must also be given).
|
||||
|
||||
@item -rdynamic
|
||||
Export global symbols to the dynamic linker. It is useful when a library
|
||||
opened with @code{dlopen()} needs to access executable symbols.
|
||||
|
||||
@item -r
|
||||
Generate an object file combining all input files (@option{-o} option must
|
||||
also be given).
|
||||
@@ -222,8 +277,24 @@ Display N callers in stack traces. This is useful with @option{-g} or
|
||||
|
||||
@end table
|
||||
|
||||
Note: GCC options @option{-Ox}, @option{-Wx}, @option{-fx} and @option{-mx} are
|
||||
Note: GCC options @option{-Ox}, @option{-fx} and @option{-mx} are
|
||||
ignored.
|
||||
@c man end
|
||||
|
||||
@ignore
|
||||
|
||||
@setfilename tcc
|
||||
@settitle Tiny C Compiler
|
||||
|
||||
@c man begin SEEALSO
|
||||
gcc(1)
|
||||
@c man end
|
||||
|
||||
@c man begin AUTHOR
|
||||
Fabrice Bellard
|
||||
@c man end
|
||||
|
||||
@end ignore
|
||||
|
||||
@chapter C language support
|
||||
|
||||
@@ -413,6 +484,9 @@ TCC includes its own x86 inline assembler with a @code{gas}-like (GNU
|
||||
assembler) syntax. No intermediate files are generated. GCC 3.x named
|
||||
operands are supported.
|
||||
|
||||
@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()}
|
||||
are supported.
|
||||
|
||||
@end itemize
|
||||
|
||||
@section TinyCC extensions
|
||||
@@ -510,6 +584,12 @@ They can be defined several times in the same source. Use 'b'
|
||||
@cindex .short
|
||||
@cindex .int
|
||||
@cindex .long
|
||||
@cindex .string
|
||||
@cindex .globl
|
||||
@cindex .section
|
||||
@cindex .text
|
||||
@cindex .data
|
||||
@cindex .bss
|
||||
|
||||
All directives are preceeded by a '.'. The following directives are
|
||||
supported:
|
||||
@@ -523,6 +603,12 @@ supported:
|
||||
@item .short value1[,value2...]
|
||||
@item .int value1[,value2...]
|
||||
@item .long value1[,value2...]
|
||||
@item .string string
|
||||
@item .global symbol
|
||||
@item .section section
|
||||
@item .text
|
||||
@item .data
|
||||
@item .bss
|
||||
@end itemize
|
||||
|
||||
@section X86 Assembler
|
||||
@@ -545,13 +631,13 @@ executable ELF files and dynamic ELF libraries without relying on an
|
||||
external linker.
|
||||
|
||||
Dynamic ELF libraries can be output but the C compiler does not generate
|
||||
position independent code (PIC). It means that the dynamic librairy
|
||||
position independent code (PIC). It means that the dynamic library
|
||||
code generated by TCC cannot be factorized among processes yet.
|
||||
|
||||
TCC linker cannot currently eliminate unused object code. But TCC
|
||||
will soon integrate a novel feature not found in GNU tools: unused code
|
||||
will be eliminated at the function or variable level, provided you only
|
||||
use TCC to compile your files.
|
||||
TCC linker eliminates unreferenced object code in libraries. A single pass is
|
||||
done on the object and library list, so the order in which object files and
|
||||
libraries are specified is important (same constraint as GNU ld). No grouping
|
||||
options (@option{--start-group} and @option{--end-group}) are supported.
|
||||
|
||||
@section ELF file loader
|
||||
|
||||
@@ -563,12 +649,15 @@ libraries (.so).
|
||||
@cindex linker scripts
|
||||
@cindex GROUP, linker command
|
||||
@cindex FILE, linker command
|
||||
@cindex OUTPUT_FORMAT, linker command
|
||||
@cindex TARGET, linker command
|
||||
|
||||
Because on many Linux systems some dynamic libraries (such as
|
||||
@file{/usr/lib/libc.so}) are in fact GNU ld link scripts (horrible!),
|
||||
the TCC linker also supports a subset of GNU ld scripts.
|
||||
|
||||
The @code{GROUP} and @code{FILE} commands are supported.
|
||||
The @code{GROUP} and @code{FILE} commands are supported. @code{OUTPUT_FORMAT}
|
||||
and @code{TARGET} are ignored.
|
||||
|
||||
Example from @file{/usr/lib/libc.so}:
|
||||
@example
|
||||
|
||||
136
tcc.1
136
tcc.1
@@ -1,136 +0,0 @@
|
||||
.TH TCC 1 "2002 Feb 6" TCC
|
||||
.SH NAME
|
||||
tcc \- tiny C compiler - the smallest ANSI C compiler
|
||||
.SH SYNOPSIS
|
||||
.B tcc
|
||||
[-\fBI\fP\fIdir\fP]
|
||||
[-\fBD\fP\fImacro\fP[=\fIdefn\fP]]
|
||||
[-\fBU\fP\fIsym\fP]
|
||||
[-\fBl\fP\fIlib\fP]
|
||||
[-\fBg\fP]
|
||||
[-\fBb\fP]
|
||||
[-\fBi\fP\fI<file>\fP]
|
||||
<file>
|
||||
[infile_args...]
|
||||
.SH DESCRIPTION
|
||||
|
||||
\fItcc\fP (tiny C compiler) is small, fast, unlimited, and safe. You
|
||||
can compile and execute C code everywhere (e.g., on rescue disks). It
|
||||
generates optimized x86 code, and can compile, assemble, and link
|
||||
several times faster than 'gcc -O0'. Any C dynamic library can be
|
||||
used directly. It includes an optional memory and bounds checker, and
|
||||
bounds-checked code can be mixed freely with standard code. C script
|
||||
is also supported--just add '#!/usr/bin/tcc' at the first line of your
|
||||
C source, and execute it directly from the command line.
|
||||
|
||||
.TP
|
||||
.BI "\-I" "dir"
|
||||
Append directory \c
|
||||
.I dir\c
|
||||
\& to the list of directories searched for include files.
|
||||
.TP
|
||||
.BI \-D macro
|
||||
Define macro \c
|
||||
.I macro\c
|
||||
\& with the string `\|\c
|
||||
.B 1\c
|
||||
\&\|' as its definition.
|
||||
.TP
|
||||
.BI \-D macro = defn
|
||||
Define macro \c
|
||||
.I macro\c
|
||||
\& as \c
|
||||
.I defn\c
|
||||
\&. All instances of `\|\c
|
||||
.B \-D\c
|
||||
\&\|' on
|
||||
the command line are processed before any `\|\c
|
||||
.B \-U\c
|
||||
\&\|' options.
|
||||
.TP
|
||||
.BI \-U macro
|
||||
Undefine macro \c
|
||||
.I macro\c
|
||||
\&. `\|\c
|
||||
.B \-U\c
|
||||
\&\|' options are evaluated after all `\|\c
|
||||
.B \-D\c
|
||||
\&\|' options, but before any `\|\c
|
||||
.B \-include\c
|
||||
\&\|' and `\|\c
|
||||
.B \-imacros\c
|
||||
\&\|' options.
|
||||
.TP
|
||||
.BI \-l library
|
||||
Use the library named \c
|
||||
.I library\c
|
||||
\& when linking.
|
||||
|
||||
|
||||
.TP
|
||||
\fB\-l\fRlib
|
||||
link with dynamic library 'lib'
|
||||
.TP
|
||||
\fB\-g\f
|
||||
generate runtime debug info
|
||||
.TP
|
||||
\fB\-b\f
|
||||
compile with built-in memory and bounds checker (implies -g)
|
||||
.TP
|
||||
\fB\-i\fR <file>
|
||||
compile <file>
|
||||
.SH SEE ALSO
|
||||
\fIgcc\fP(1)
|
||||
.SH PROBLEMS AND BUGS
|
||||
We haven't found any bugs yet. Perhaps there are bugs but it's
|
||||
unlikely.
|
||||
|
||||
If you have problems with `tcc' or think you've found a
|
||||
bug, please report it to the developers; we cannot promise to do
|
||||
anything but we might well want to fix it.
|
||||
|
||||
Before reporting a bug, make sure you've actually found a real bug.
|
||||
Carefully reread the documentation and see if it really says you can
|
||||
do what you're trying to do. If it's not clear whether you should be
|
||||
able to do something or not, report that too; it's a bug in the
|
||||
documentation!
|
||||
|
||||
Before reporting a bug or trying to fix it yourself, try to isolate it
|
||||
to the smallest possible conditions that reproduces the problem. Then
|
||||
send us the description and the exact results `tcc' gave
|
||||
you. Also say what you expected to occur; this will help us decide
|
||||
whether the problem was really in the documentation.
|
||||
|
||||
Once you've got a precise problem, please send electronic mail to:
|
||||
|
||||
Fabrice Bellard <fabrice.bellard@free.fr>
|
||||
|
||||
Please include the version number of `tcc' you are using.
|
||||
Be sure also to include the type of machine and operating system you
|
||||
are using.
|
||||
.SH COPYRIGHT
|
||||
\fItcc\fP is Copyright \(co 2001, 2002 by Fabrice Bellard
|
||||
.PP
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual page provided the copyright notice and this permission
|
||||
notice are preserved on all copies.
|
||||
.ig
|
||||
Permission is granted to process this file through troff and print the
|
||||
results, provided the printed document carries copying permission
|
||||
notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual page).
|
||||
..
|
||||
.PP
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual page under the conditions for verbatim copying, provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
.PP
|
||||
Permission is granted to copy and distribute translations of this
|
||||
manual page into another language, under the above conditions for
|
||||
modified versions, except that this permission notice may be stated in
|
||||
a translation approved by the Foundation.
|
||||
.SH AUTHORS
|
||||
This program was written by Fabrice Bellard <fabrice.bellard@free.fr>.
|
||||
It may be freely distributed under the terms of the GNU General Public
|
||||
License. There is ABSOLUTELY NO WARRANTY for this program.
|
||||
104
tccasm.c
104
tccasm.c
@@ -3,19 +3,19 @@
|
||||
*
|
||||
* Copyright (c) 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
static int asm_get_local_label_name(TCCState *s1, unsigned int n)
|
||||
@@ -40,7 +40,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
|
||||
switch(tok) {
|
||||
case TOK_PPNUM:
|
||||
p = tokc.cstr->data;
|
||||
n = strtol(p, (char **)&p, 0);
|
||||
n = strtoul(p, (char **)&p, 0);
|
||||
if (*p == 'b' || *p == 'f') {
|
||||
/* backward or forward label */
|
||||
label = asm_get_local_label_name(s1, n);
|
||||
@@ -85,6 +85,12 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
|
||||
else
|
||||
pe->v = ~pe->v;
|
||||
break;
|
||||
case TOK_CCHAR:
|
||||
case TOK_LCHAR:
|
||||
pe->v = tokc.i;
|
||||
pe->sym = NULL;
|
||||
next();
|
||||
break;
|
||||
default:
|
||||
if (tok >= TOK_IDENT) {
|
||||
/* label case : if the label was not found, add one */
|
||||
@@ -276,6 +282,15 @@ static void asm_free_labels(TCCState *st)
|
||||
st->asm_labels = NULL;
|
||||
}
|
||||
|
||||
static void use_section(TCCState *s1, const char *name)
|
||||
{
|
||||
Section *sec;
|
||||
sec = find_section(s1, name);
|
||||
cur_text_section->data_offset = ind;
|
||||
cur_text_section = sec;
|
||||
ind = cur_text_section->data_offset;
|
||||
}
|
||||
|
||||
static void asm_parse_directive(TCCState *s1)
|
||||
{
|
||||
int n, offset, v, size, tok1;
|
||||
@@ -346,8 +361,69 @@ static void asm_parse_directive(TCCState *s1)
|
||||
next();
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_globl:
|
||||
{
|
||||
Sym *sym;
|
||||
|
||||
next();
|
||||
sym = label_find(tok);
|
||||
if (!sym) {
|
||||
sym = label_push(&s1->asm_labels, tok, 0);
|
||||
sym->type.t = VT_VOID;
|
||||
}
|
||||
sym->type.t &= ~VT_STATIC;
|
||||
next();
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_string:
|
||||
{
|
||||
const uint8_t *p;
|
||||
int i;
|
||||
|
||||
next();
|
||||
if (tok != TOK_STR)
|
||||
expect("string constant");
|
||||
p = tokc.cstr->data;
|
||||
for(i = 0; i < tokc.cstr->size; i++)
|
||||
g(p[i]);
|
||||
next();
|
||||
}
|
||||
break;
|
||||
case TOK_ASM_text:
|
||||
case TOK_ASM_data:
|
||||
case TOK_ASM_bss:
|
||||
{
|
||||
char sname[64];
|
||||
tok1 = tok;
|
||||
n = 0;
|
||||
next();
|
||||
if (tok != ';' && tok != TOK_LINEFEED) {
|
||||
n = asm_int_expr(s1);
|
||||
next();
|
||||
}
|
||||
sprintf(sname, (n?".%s%d":".%s"), get_tok_str(tok1, NULL), n);
|
||||
use_section(s1, sname);
|
||||
}
|
||||
break;
|
||||
case TOK_SECTION1:
|
||||
{
|
||||
char sname[256];
|
||||
|
||||
/* XXX: support more options */
|
||||
next();
|
||||
sname[0] = '\0';
|
||||
while (tok != ';' && tok != TOK_LINEFEED && tok != ',') {
|
||||
if (tok == TOK_STR)
|
||||
pstrcat(sname, sizeof(sname), tokc.cstr->data);
|
||||
else
|
||||
pstrcat(sname, sizeof(sname), get_tok_str(tok, NULL));
|
||||
next();
|
||||
}
|
||||
use_section(s1, sname);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error("unknown assembler directive .%s", get_tok_str(tok, NULL));
|
||||
error("unknown assembler directive '.%s'", get_tok_str(tok, NULL));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -413,7 +489,7 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess)
|
||||
const char *p;
|
||||
int n;
|
||||
p = tokc.cstr->data;
|
||||
n = strtol(p, (char **)&p, 10);
|
||||
n = strtoul(p, (char **)&p, 10);
|
||||
if (*p != '\0')
|
||||
expect("':'");
|
||||
/* new local label */
|
||||
|
||||
219
tccelf.c
219
tccelf.c
@@ -3,19 +3,19 @@
|
||||
*
|
||||
* Copyright (c) 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
static int put_elf_str(Section *s, const char *sym)
|
||||
@@ -154,16 +154,25 @@ static int find_elf_sym(Section *s, const char *name)
|
||||
}
|
||||
|
||||
/* return elf symbol value or error */
|
||||
void *tcc_get_symbol(TCCState *s, const char *name)
|
||||
int tcc_get_symbol(TCCState *s, unsigned long *pval, const char *name)
|
||||
{
|
||||
int sym_index;
|
||||
Elf32_Sym *sym;
|
||||
|
||||
sym_index = find_elf_sym(symtab_section, name);
|
||||
if (!sym_index)
|
||||
error("%s not defined", name);
|
||||
return -1;
|
||||
sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
|
||||
return (void *)sym->st_value;
|
||||
*pval = sym->st_value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *tcc_get_symbol_err(TCCState *s, const char *name)
|
||||
{
|
||||
unsigned long val;
|
||||
if (tcc_get_symbol(s, &val, name) < 0)
|
||||
error("%s not defined", name);
|
||||
return (void *)val;
|
||||
}
|
||||
|
||||
/* add an elf symbol : check if it is already defined and patch
|
||||
@@ -771,6 +780,34 @@ static void put_dt(Section *dynamic, int dt, unsigned long val)
|
||||
dyn->d_un.d_val = val;
|
||||
}
|
||||
|
||||
static void add_init_array_defines(TCCState *s1, const char *section_name)
|
||||
{
|
||||
Section *s;
|
||||
long end_offset;
|
||||
char sym_start[1024];
|
||||
char sym_end[1024];
|
||||
|
||||
snprintf(sym_start, sizeof(sym_start), "__%s_start", section_name + 1);
|
||||
snprintf(sym_end, sizeof(sym_end), "__%s_end", section_name + 1);
|
||||
|
||||
s = find_section(s1, section_name);
|
||||
if (!s) {
|
||||
end_offset = 0;
|
||||
s = data_section;
|
||||
} else {
|
||||
end_offset = s->data_offset;
|
||||
}
|
||||
|
||||
add_elf_sym(symtab_section,
|
||||
0, 0,
|
||||
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
||||
s->sh_num, sym_start);
|
||||
add_elf_sym(symtab_section,
|
||||
end_offset, 0,
|
||||
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
||||
s->sh_num, sym_end);
|
||||
}
|
||||
|
||||
/* add tcc runtime libraries */
|
||||
static void tcc_add_runtime(TCCState *s1)
|
||||
{
|
||||
@@ -778,8 +815,10 @@ static void tcc_add_runtime(TCCState *s1)
|
||||
int i;
|
||||
Section *s;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.o");
|
||||
tcc_add_file(s1, buf);
|
||||
if (!s1->nostdlib) {
|
||||
snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.a");
|
||||
tcc_add_file(s1, buf);
|
||||
}
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
if (do_bounds_check) {
|
||||
unsigned long *ptr;
|
||||
@@ -810,9 +849,12 @@ static void tcc_add_runtime(TCCState *s1)
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/* add libc if not memory output */
|
||||
if (s1->output_type != TCC_OUTPUT_MEMORY) {
|
||||
/* add libc */
|
||||
if (!s1->nostdlib) {
|
||||
tcc_add_library(s1, "c");
|
||||
}
|
||||
/* add crt end if not memory output */
|
||||
if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) {
|
||||
tcc_add_file(s1, CONFIG_TCC_CRT_PREFIX "/crtn.o");
|
||||
}
|
||||
/* add various standard linker symbols */
|
||||
@@ -828,6 +870,11 @@ static void tcc_add_runtime(TCCState *s1)
|
||||
bss_section->data_offset, 0,
|
||||
ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE),
|
||||
bss_section->sh_num, "_end");
|
||||
/* horrible new standard ldscript defines */
|
||||
add_init_array_defines(s1, ".preinit_array");
|
||||
add_init_array_defines(s1, ".init_array");
|
||||
add_init_array_defines(s1, ".fini_array");
|
||||
|
||||
/* add start and stop symbols for sections whose name can be
|
||||
expressed in C */
|
||||
for(i = 1; i < s1->nb_sections; i++) {
|
||||
@@ -965,7 +1012,7 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
||||
unsigned long offset;
|
||||
offset = bss_section->data_offset;
|
||||
/* XXX: which alignment ? */
|
||||
offset = (offset + 8 - 1) & -8;
|
||||
offset = (offset + 16 - 1) & -16;
|
||||
index = put_elf_sym(s1->dynsym, offset, esym->st_size,
|
||||
esym->st_info, 0,
|
||||
bss_section->sh_num, name);
|
||||
@@ -984,6 +1031,14 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
||||
error_noabort("undefined symbol '%s'", name);
|
||||
}
|
||||
}
|
||||
} else if (s1->rdynamic &&
|
||||
ELF32_ST_BIND(sym->st_info) != STB_LOCAL) {
|
||||
/* if -rdynamic option, then export all non
|
||||
local symbols */
|
||||
name = symtab_section->link->data + sym->st_name;
|
||||
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
|
||||
sym->st_info, 0,
|
||||
sym->st_shndx, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1001,6 +1056,8 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
||||
name = s1->dynsymtab_section->link->data + esym->st_name;
|
||||
sym_index = find_elf_sym(symtab_section, name);
|
||||
if (sym_index) {
|
||||
/* XXX: avoid adding a symbol if already
|
||||
present because of -rdynamic ? */
|
||||
sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
|
||||
put_elf_sym(s1->dynsym, sym->st_value, sym->st_size,
|
||||
sym->st_info, 0,
|
||||
@@ -1248,12 +1305,14 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
||||
|
||||
p = s1->plt->data;
|
||||
p_end = p + s1->plt->data_offset;
|
||||
put32(p + 2, get32(p + 2) + s1->got->sh_addr);
|
||||
put32(p + 8, get32(p + 8) + s1->got->sh_addr);
|
||||
p += 16;
|
||||
while (p < p_end) {
|
||||
if (p < p_end) {
|
||||
put32(p + 2, get32(p + 2) + s1->got->sh_addr);
|
||||
put32(p + 8, get32(p + 8) + s1->got->sh_addr);
|
||||
p += 16;
|
||||
while (p < p_end) {
|
||||
put32(p + 2, get32(p + 2) + s1->got->sh_addr);
|
||||
p += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1336,7 +1395,7 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
||||
|
||||
/* get entry point address */
|
||||
if (file_type == TCC_OUTPUT_EXE)
|
||||
ehdr.e_entry = (unsigned long)tcc_get_symbol(s1, "_start");
|
||||
ehdr.e_entry = (unsigned long)tcc_get_symbol_err(s1, "_start");
|
||||
else
|
||||
ehdr.e_entry = text_section->sh_addr; /* XXX: is it correct ? */
|
||||
}
|
||||
@@ -1452,7 +1511,8 @@ static void *load_data(int fd, unsigned long file_offset, unsigned long size)
|
||||
typedef struct SectionMergeInfo {
|
||||
Section *s; /* corresponding existing section */
|
||||
unsigned long offset; /* offset of the new section in the existing section */
|
||||
int new_section; /* true if section 's' was added */
|
||||
uint8_t new_section; /* true if section 's' was added */
|
||||
uint8_t link_once; /* true if link once section */
|
||||
} SectionMergeInfo;
|
||||
|
||||
/* load an object file and merge it with current files */
|
||||
@@ -1539,8 +1599,19 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
/* find corresponding section, if any */
|
||||
for(j = 1; j < s1->nb_sections;j++) {
|
||||
s = s1->sections[j];
|
||||
if (!strcmp(s->name, sh_name))
|
||||
goto found;
|
||||
if (!strcmp(s->name, sh_name)) {
|
||||
if (!strncmp(sh_name, ".gnu.linkonce",
|
||||
sizeof(".gnu.linkonce") - 1)) {
|
||||
/* if a 'linkonce' section is already present, we
|
||||
do not add it again. It is a little tricky as
|
||||
symbols can still be defined in
|
||||
it. */
|
||||
sm_table[i].link_once = 1;
|
||||
goto next;
|
||||
} else {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* not found: create new section */
|
||||
s = new_section(s1, sh_name, sh->sh_type, sh->sh_flags);
|
||||
@@ -1574,6 +1645,7 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
} else {
|
||||
s->data_offset += size;
|
||||
}
|
||||
next: ;
|
||||
}
|
||||
|
||||
/* second short pass to update sh_link and sh_info fields of new
|
||||
@@ -1601,6 +1673,18 @@ static int tcc_load_object_file(TCCState *s1,
|
||||
if (sym->st_shndx != SHN_UNDEF &&
|
||||
sym->st_shndx < SHN_LORESERVE) {
|
||||
sm = &sm_table[sym->st_shndx];
|
||||
if (sm->link_once) {
|
||||
/* if a symbol is in a link once section, we use the
|
||||
already defined symbol. It is very important to get
|
||||
correct relocations */
|
||||
if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL) {
|
||||
name = strtab + sym->st_name;
|
||||
sym_index = find_elf_sym(symtab_section, name);
|
||||
if (sym_index)
|
||||
old_to_new_syms[i] = sym_index;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* if no corresponding section added, no need to add symbol */
|
||||
if (!sm->s)
|
||||
continue;
|
||||
@@ -1678,6 +1762,55 @@ typedef struct ArchiveHeader {
|
||||
char ar_fmag[2]; /* should contain ARFMAG */
|
||||
} ArchiveHeader;
|
||||
|
||||
static int get_be32(const uint8_t *b)
|
||||
{
|
||||
return b[3] | (b[2] << 8) | (b[1] << 16) | (b[0] << 24);
|
||||
}
|
||||
|
||||
/* load only the objects which resolve undefined symbols */
|
||||
static int tcc_load_alacarte(TCCState *s1, int fd, int size)
|
||||
{
|
||||
int i, bound, nsyms, sym_index, off, ret;
|
||||
uint8_t *data;
|
||||
const char *ar_names, *p;
|
||||
const uint8_t *ar_index;
|
||||
Elf32_Sym *sym;
|
||||
|
||||
data = tcc_malloc(size);
|
||||
if (read(fd, data, size) != size)
|
||||
goto fail;
|
||||
nsyms = get_be32(data);
|
||||
ar_index = data + 4;
|
||||
ar_names = ar_index + nsyms * 4;
|
||||
|
||||
do {
|
||||
bound = 0;
|
||||
for(p = ar_names, i = 0; i < nsyms; i++, p += strlen(p)+1) {
|
||||
sym_index = find_elf_sym(symtab_section, p);
|
||||
if(sym_index) {
|
||||
sym = &((Elf32_Sym *)symtab_section->data)[sym_index];
|
||||
if(sym->st_shndx == SHN_UNDEF) {
|
||||
off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader);
|
||||
#if 0
|
||||
printf("%5d\t%s\t%08x\n", i, p, sym->st_shndx);
|
||||
#endif
|
||||
++bound;
|
||||
lseek(fd, off, SEEK_SET);
|
||||
if(tcc_load_object_file(s1, fd, off) < 0) {
|
||||
fail:
|
||||
ret = -1;
|
||||
goto the_end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(bound);
|
||||
ret = 0;
|
||||
the_end:
|
||||
tcc_free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* load a '.a' file */
|
||||
static int tcc_load_archive(TCCState *s1, int fd)
|
||||
{
|
||||
@@ -1710,18 +1843,21 @@ static int tcc_load_archive(TCCState *s1, int fd)
|
||||
ar_name[i + 1] = '\0';
|
||||
// printf("name='%s' size=%d %s\n", ar_name, size, ar_size);
|
||||
file_offset = lseek(fd, 0, SEEK_CUR);
|
||||
if (!strcmp(ar_name, "/") ||
|
||||
!strcmp(ar_name, "//") ||
|
||||
!strcmp(ar_name, "__.SYMDEF") ||
|
||||
!strcmp(ar_name, "__.SYMDEF/") ||
|
||||
!strcmp(ar_name, "ARFILENAMES/")) {
|
||||
/* align to even */
|
||||
size = (size + 1) & ~1;
|
||||
if (!strcmp(ar_name, "/")) {
|
||||
/* coff symbol table : we handle it */
|
||||
if(s1->alacarte_link)
|
||||
return tcc_load_alacarte(s1, fd, size);
|
||||
} else if (!strcmp(ar_name, "//") ||
|
||||
!strcmp(ar_name, "__.SYMDEF") ||
|
||||
!strcmp(ar_name, "__.SYMDEF/") ||
|
||||
!strcmp(ar_name, "ARFILENAMES/")) {
|
||||
/* skip symbol table or archive names */
|
||||
} else {
|
||||
if (tcc_load_object_file(s1, fd, file_offset) < 0)
|
||||
return -1;
|
||||
}
|
||||
/* align to even */
|
||||
size = (size + 1) & ~1;
|
||||
lseek(fd, file_offset + size, SEEK_SET);
|
||||
}
|
||||
return 0;
|
||||
@@ -1954,6 +2090,21 @@ static int tcc_load_ldscript(TCCState *s1)
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(cmd, "OUTPUT_FORMAT") ||
|
||||
!strcmp(cmd, "TARGET")) {
|
||||
/* ignore some commands */
|
||||
t = ld_next(s1, cmd, sizeof(cmd));
|
||||
if (t != '(')
|
||||
expect("(");
|
||||
for(;;) {
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
if (t == LD_TOK_EOF) {
|
||||
error_noabort("unexpected end of file");
|
||||
return -1;
|
||||
} else if (t == ')') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
60
tcctest.c
60
tcctest.c
@@ -76,6 +76,7 @@ void typeof_test(void);
|
||||
void local_label_test(void);
|
||||
void statement_expr_test(void);
|
||||
void asm_test(void);
|
||||
void builtin_test(void);
|
||||
|
||||
int fib(int n);
|
||||
void num(int n);
|
||||
@@ -122,6 +123,12 @@ int isid(int c);
|
||||
#define __INT64_C(c) c ## LL
|
||||
#define INT64_MIN (-__INT64_C(9223372036854775807)-1)
|
||||
|
||||
int qq(int x)
|
||||
{
|
||||
return x + 40;
|
||||
}
|
||||
#define qq(x) x
|
||||
|
||||
void macro_test(void)
|
||||
{
|
||||
printf("macro:\n");
|
||||
@@ -209,7 +216,7 @@ void macro_test(void)
|
||||
#line 203 "test"
|
||||
printf("__LINE__=%d __FILE__=%s\n",
|
||||
__LINE__, __FILE__);
|
||||
#line 206 "tcctest.c"
|
||||
#line 220 "tcctest.c"
|
||||
|
||||
/* not strictly preprocessor, but we test it there */
|
||||
#ifdef C99_MACROS
|
||||
@@ -243,6 +250,15 @@ void macro_test(void)
|
||||
MF_s("hi");
|
||||
MF_t("hi");
|
||||
|
||||
/* test macro substituion inside args (should not eat stream) */
|
||||
printf("qq=%d\n", qq(qq)(2));
|
||||
|
||||
/* test zero argument case. NOTE: gcc 2.95.x does not accept a
|
||||
null argument without a space. gcc 3.2 fixes that. */
|
||||
|
||||
#define qq1(x) 1
|
||||
printf("qq1=%d\n", qq1( ));
|
||||
|
||||
/* comment with stray handling *\
|
||||
/
|
||||
/* this is a valid *\/ comment */
|
||||
@@ -265,7 +281,7 @@ int ret(a)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ps(char *s)
|
||||
void ps(const char *s)
|
||||
{
|
||||
int c;
|
||||
while (1) {
|
||||
@@ -498,6 +514,7 @@ int main(int argc, char **argv)
|
||||
statement_expr_test();
|
||||
local_label_test();
|
||||
asm_test();
|
||||
builtin_test();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1897,3 +1914,42 @@ void asm_test(void)
|
||||
void asm_test(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define COMPAT_TYPE(type1, type2) \
|
||||
{\
|
||||
printf("__builtin_types_compatible_p(%s, %s) = %d\n", #type1, #type2, \
|
||||
__builtin_types_compatible_p (type1, type2));\
|
||||
}
|
||||
|
||||
int constant_p_var;
|
||||
|
||||
void builtin_test(void)
|
||||
{
|
||||
#if GCC_MAJOR >= 3
|
||||
COMPAT_TYPE(int, int);
|
||||
COMPAT_TYPE(int, unsigned int);
|
||||
COMPAT_TYPE(int, char);
|
||||
COMPAT_TYPE(int, const int);
|
||||
COMPAT_TYPE(int, volatile int);
|
||||
COMPAT_TYPE(int *, int *);
|
||||
COMPAT_TYPE(int *, void *);
|
||||
COMPAT_TYPE(int *, const int *);
|
||||
COMPAT_TYPE(char *, unsigned char *);
|
||||
/* space is needed because tcc preprocessor introduces a space between each token */
|
||||
COMPAT_TYPE(char * *, void *);
|
||||
#endif
|
||||
printf("res = %d\n", __builtin_constant_p(1));
|
||||
printf("res = %d\n", __builtin_constant_p(1 + 2));
|
||||
printf("res = %d\n", __builtin_constant_p(&constant_p_var));
|
||||
printf("res = %d\n", __builtin_constant_p(constant_p_var));
|
||||
}
|
||||
|
||||
|
||||
void const_func(const int a)
|
||||
{
|
||||
}
|
||||
|
||||
void const_warn_test(void)
|
||||
{
|
||||
|
||||
9
tcctok.h
9
tcctok.h
@@ -100,6 +100,8 @@
|
||||
DEF(TOK_STDCALL3, "__stdcall__")
|
||||
DEF(TOK_NORETURN1, "noreturn")
|
||||
DEF(TOK_NORETURN2, "__noreturn__")
|
||||
DEF(TOK_builtin_types_compatible_p, "__builtin_types_compatible_p")
|
||||
DEF(TOK_builtin_constant_p, "__builtin_constant_p")
|
||||
|
||||
/* builtin functions or variables */
|
||||
DEF(TOK_memcpy, "memcpy")
|
||||
@@ -142,12 +144,17 @@
|
||||
DEF(TOK_strcpy, "strcpy")
|
||||
#endif
|
||||
|
||||
/* Tiny Assembler for x86 */
|
||||
/* Tiny Assembler */
|
||||
|
||||
DEF_ASM(byte)
|
||||
DEF_ASM(align)
|
||||
DEF_ASM(skip)
|
||||
DEF_ASM(space)
|
||||
DEF_ASM(string)
|
||||
DEF_ASM(globl)
|
||||
DEF_ASM(text)
|
||||
DEF_ASM(data)
|
||||
DEF_ASM(bss)
|
||||
|
||||
#ifdef TCC_TARGET_I386
|
||||
|
||||
|
||||
427
texi2pod.pl
Executable file
427
texi2pod.pl
Executable file
@@ -0,0 +1,427 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU CC.
|
||||
|
||||
# GNU CC is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# GNU CC is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU CC; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
# Boston MA 02111-1307, USA.
|
||||
|
||||
# This does trivial (and I mean _trivial_) conversion of Texinfo
|
||||
# markup to Perl POD format. It's intended to be used to extract
|
||||
# something suitable for a manpage from a Texinfo document.
|
||||
|
||||
$output = 0;
|
||||
$skipping = 0;
|
||||
%sects = ();
|
||||
$section = "";
|
||||
@icstack = ();
|
||||
@endwstack = ();
|
||||
@skstack = ();
|
||||
@instack = ();
|
||||
$shift = "";
|
||||
%defs = ();
|
||||
$fnno = 1;
|
||||
$inf = "";
|
||||
$ibase = "";
|
||||
|
||||
while ($_ = shift) {
|
||||
if (/^-D(.*)$/) {
|
||||
if ($1 ne "") {
|
||||
$flag = $1;
|
||||
} else {
|
||||
$flag = shift;
|
||||
}
|
||||
$value = "";
|
||||
($flag, $value) = ($flag =~ /^([^=]+)(?:=(.+))?/);
|
||||
die "no flag specified for -D\n"
|
||||
unless $flag ne "";
|
||||
die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
|
||||
unless $flag =~ /^[a-zA-Z0-9_-]+$/;
|
||||
$defs{$flag} = $value;
|
||||
} elsif (/^-/) {
|
||||
usage();
|
||||
} else {
|
||||
$in = $_, next unless defined $in;
|
||||
$out = $_, next unless defined $out;
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $in) {
|
||||
$inf = gensym();
|
||||
open($inf, "<$in") or die "opening \"$in\": $!\n";
|
||||
$ibase = $1 if $in =~ m|^(.+)/[^/]+$|;
|
||||
} else {
|
||||
$inf = \*STDIN;
|
||||
}
|
||||
|
||||
if (defined $out) {
|
||||
open(STDOUT, ">$out") or die "opening \"$out\": $!\n";
|
||||
}
|
||||
|
||||
while(defined $inf) {
|
||||
while(<$inf>) {
|
||||
# Certain commands are discarded without further processing.
|
||||
/^\@(?:
|
||||
[a-z]+index # @*index: useful only in complete manual
|
||||
|need # @need: useful only in printed manual
|
||||
|(?:end\s+)?group # @group .. @end group: ditto
|
||||
|page # @page: ditto
|
||||
|node # @node: useful only in .info file
|
||||
|(?:end\s+)?ifnottex # @ifnottex .. @end ifnottex: use contents
|
||||
)\b/x and next;
|
||||
|
||||
chomp;
|
||||
|
||||
# Look for filename and title markers.
|
||||
/^\@setfilename\s+([^.]+)/ and $fn = $1, next;
|
||||
/^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next;
|
||||
|
||||
# Identify a man title but keep only the one we are interested in.
|
||||
/^\@c\s+man\s+title\s+([A-Za-z0-9-]+)\s+(.+)/ and do {
|
||||
if (exists $defs{$1}) {
|
||||
$fn = $1;
|
||||
$tl = postprocess($2);
|
||||
}
|
||||
next;
|
||||
};
|
||||
|
||||
# Look for blocks surrounded by @c man begin SECTION ... @c man end.
|
||||
# This really oughta be @ifman ... @end ifman and the like, but such
|
||||
# would require rev'ing all other Texinfo translators.
|
||||
/^\@c\s+man\s+begin\s+([A-Z]+)\s+([A-Za-z0-9-]+)/ and do {
|
||||
$output = 1 if exists $defs{$2};
|
||||
$sect = $1;
|
||||
next;
|
||||
};
|
||||
/^\@c\s+man\s+begin\s+([A-Z]+)/ and $sect = $1, $output = 1, next;
|
||||
/^\@c\s+man\s+end/ and do {
|
||||
$sects{$sect} = "" unless exists $sects{$sect};
|
||||
$sects{$sect} .= postprocess($section);
|
||||
$section = "";
|
||||
$output = 0;
|
||||
next;
|
||||
};
|
||||
|
||||
# handle variables
|
||||
/^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do {
|
||||
$defs{$1} = $2;
|
||||
next;
|
||||
};
|
||||
/^\@clear\s+([a-zA-Z0-9_-]+)/ and do {
|
||||
delete $defs{$1};
|
||||
next;
|
||||
};
|
||||
|
||||
next unless $output;
|
||||
|
||||
# Discard comments. (Can't do it above, because then we'd never see
|
||||
# @c man lines.)
|
||||
/^\@c\b/ and next;
|
||||
|
||||
# End-block handler goes up here because it needs to operate even
|
||||
# if we are skipping.
|
||||
/^\@end\s+([a-z]+)/ and do {
|
||||
# Ignore @end foo, where foo is not an operation which may
|
||||
# cause us to skip, if we are presently skipping.
|
||||
my $ended = $1;
|
||||
next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex)$/;
|
||||
|
||||
die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
|
||||
die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
|
||||
|
||||
$endw = pop @endwstack;
|
||||
|
||||
if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
|
||||
$skipping = pop @skstack;
|
||||
next;
|
||||
} elsif ($ended =~ /^(?:example|smallexample|display)$/) {
|
||||
$shift = "";
|
||||
$_ = ""; # need a paragraph break
|
||||
} elsif ($ended =~ /^(?:itemize|enumerate|[fv]?table)$/) {
|
||||
$_ = "\n=back\n";
|
||||
$ic = pop @icstack;
|
||||
} else {
|
||||
die "unknown command \@end $ended at line $.\n";
|
||||
}
|
||||
};
|
||||
|
||||
# We must handle commands which can cause skipping even while we
|
||||
# are skipping, otherwise we will not process nested conditionals
|
||||
# correctly.
|
||||
/^\@ifset\s+([a-zA-Z0-9_-]+)/ and do {
|
||||
push @endwstack, $endw;
|
||||
push @skstack, $skipping;
|
||||
$endw = "ifset";
|
||||
$skipping = 1 unless exists $defs{$1};
|
||||
next;
|
||||
};
|
||||
|
||||
/^\@ifclear\s+([a-zA-Z0-9_-]+)/ and do {
|
||||
push @endwstack, $endw;
|
||||
push @skstack, $skipping;
|
||||
$endw = "ifclear";
|
||||
$skipping = 1 if exists $defs{$1};
|
||||
next;
|
||||
};
|
||||
|
||||
/^\@(ignore|menu|iftex)\b/ and do {
|
||||
push @endwstack, $endw;
|
||||
push @skstack, $skipping;
|
||||
$endw = $1;
|
||||
$skipping = 1;
|
||||
next;
|
||||
};
|
||||
|
||||
next if $skipping;
|
||||
|
||||
# Character entities. First the ones that can be replaced by raw text
|
||||
# or discarded outright:
|
||||
s/\@copyright\{\}/(c)/g;
|
||||
s/\@dots\{\}/.../g;
|
||||
s/\@enddots\{\}/..../g;
|
||||
s/\@([.!? ])/$1/g;
|
||||
s/\@[:-]//g;
|
||||
s/\@bullet(?:\{\})?/*/g;
|
||||
s/\@TeX\{\}/TeX/g;
|
||||
s/\@pounds\{\}/\#/g;
|
||||
s/\@minus(?:\{\})?/-/g;
|
||||
s/\\,/,/g;
|
||||
|
||||
# Now the ones that have to be replaced by special escapes
|
||||
# (which will be turned back into text by unmunge())
|
||||
s/&/&/g;
|
||||
s/\@\{/{/g;
|
||||
s/\@\}/}/g;
|
||||
s/\@\@/&at;/g;
|
||||
|
||||
# Inside a verbatim block, handle @var specially.
|
||||
if ($shift ne "") {
|
||||
s/\@var\{([^\}]*)\}/<$1>/g;
|
||||
}
|
||||
|
||||
# POD doesn't interpret E<> inside a verbatim block.
|
||||
if ($shift eq "") {
|
||||
s/</</g;
|
||||
s/>/>/g;
|
||||
} else {
|
||||
s/</</g;
|
||||
s/>/>/g;
|
||||
}
|
||||
|
||||
# Single line command handlers.
|
||||
|
||||
/^\@include\s+(.+)$/ and do {
|
||||
push @instack, $inf;
|
||||
$inf = gensym();
|
||||
|
||||
# Try cwd and $ibase.
|
||||
open($inf, "<" . $1)
|
||||
or open($inf, "<" . $ibase . "/" . $1)
|
||||
or die "cannot open $1 or $ibase/$1: $!\n";
|
||||
next;
|
||||
};
|
||||
|
||||
/^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/
|
||||
and $_ = "\n=head2 $1\n";
|
||||
/^\@subsection\s+(.+)$/
|
||||
and $_ = "\n=head3 $1\n";
|
||||
|
||||
# Block command handlers:
|
||||
/^\@itemize\s+(\@[a-z]+|\*|-)/ and do {
|
||||
push @endwstack, $endw;
|
||||
push @icstack, $ic;
|
||||
$ic = $1;
|
||||
$_ = "\n=over 4\n";
|
||||
$endw = "itemize";
|
||||
};
|
||||
|
||||
/^\@enumerate(?:\s+([a-zA-Z0-9]+))?/ and do {
|
||||
push @endwstack, $endw;
|
||||
push @icstack, $ic;
|
||||
if (defined $1) {
|
||||
$ic = $1 . ".";
|
||||
} else {
|
||||
$ic = "1.";
|
||||
}
|
||||
$_ = "\n=over 4\n";
|
||||
$endw = "enumerate";
|
||||
};
|
||||
|
||||
/^\@([fv]?table)\s+(\@[a-z]+)/ and do {
|
||||
push @endwstack, $endw;
|
||||
push @icstack, $ic;
|
||||
$endw = $1;
|
||||
$ic = $2;
|
||||
$ic =~ s/\@(?:samp|strong|key|gcctabopt|option|env)/B/;
|
||||
$ic =~ s/\@(?:code|kbd)/C/;
|
||||
$ic =~ s/\@(?:dfn|var|emph|cite|i)/I/;
|
||||
$ic =~ s/\@(?:file)/F/;
|
||||
$_ = "\n=over 4\n";
|
||||
};
|
||||
|
||||
/^\@((?:small)?example|display)/ and do {
|
||||
push @endwstack, $endw;
|
||||
$endw = $1;
|
||||
$shift = "\t";
|
||||
$_ = ""; # need a paragraph break
|
||||
};
|
||||
|
||||
/^\@itemx?\s*(.+)?$/ and do {
|
||||
if (defined $1) {
|
||||
# Entity escapes prevent munging by the <> processing below.
|
||||
$_ = "\n=item $ic\<$1\>\n";
|
||||
} else {
|
||||
$_ = "\n=item $ic\n";
|
||||
$ic =~ y/A-Ya-y/B-Zb-z/;
|
||||
$ic =~ s/(\d+)/$1 + 1/eg;
|
||||
}
|
||||
};
|
||||
|
||||
$section .= $shift.$_."\n";
|
||||
}
|
||||
# End of current file.
|
||||
close($inf);
|
||||
$inf = pop @instack;
|
||||
}
|
||||
|
||||
die "No filename or title\n" unless defined $fn && defined $tl;
|
||||
|
||||
$sects{NAME} = "$fn \- $tl\n";
|
||||
$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES};
|
||||
|
||||
for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS ENVIRONMENT FILES
|
||||
BUGS NOTES FOOTNOTES SEEALSO AUTHOR COPYRIGHT)) {
|
||||
if(exists $sects{$sect}) {
|
||||
$head = $sect;
|
||||
$head =~ s/SEEALSO/SEE ALSO/;
|
||||
print "=head1 $head\n\n";
|
||||
print scalar unmunge ($sects{$sect});
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
die "usage: $0 [-D toggle...] [infile [outfile]]\n";
|
||||
}
|
||||
|
||||
sub postprocess
|
||||
{
|
||||
local $_ = $_[0];
|
||||
|
||||
# @value{foo} is replaced by whatever 'foo' is defined as.
|
||||
while (m/(\@value\{([a-zA-Z0-9_-]+)\})/g) {
|
||||
if (! exists $defs{$2}) {
|
||||
print STDERR "Option $2 not defined\n";
|
||||
s/\Q$1\E//;
|
||||
} else {
|
||||
$value = $defs{$2};
|
||||
s/\Q$1\E/$value/;
|
||||
}
|
||||
}
|
||||
|
||||
# Formatting commands.
|
||||
# Temporary escape for @r.
|
||||
s/\@r\{([^\}]*)\}/R<$1>/g;
|
||||
s/\@(?:dfn|var|emph|cite|i)\{([^\}]*)\}/I<$1>/g;
|
||||
s/\@(?:code|kbd)\{([^\}]*)\}/C<$1>/g;
|
||||
s/\@(?:gccoptlist|samp|strong|key|option|env|command|b)\{([^\}]*)\}/B<$1>/g;
|
||||
s/\@sc\{([^\}]*)\}/\U$1/g;
|
||||
s/\@file\{([^\}]*)\}/F<$1>/g;
|
||||
s/\@w\{([^\}]*)\}/S<$1>/g;
|
||||
s/\@(?:dmn|math)\{([^\}]*)\}/$1/g;
|
||||
|
||||
# Cross references are thrown away, as are @noindent and @refill.
|
||||
# (@noindent is impossible in .pod, and @refill is unnecessary.)
|
||||
# @* is also impossible in .pod; we discard it and any newline that
|
||||
# follows it. Similarly, our macro @gol must be discarded.
|
||||
|
||||
s/\(?\@xref\{(?:[^\}]*)\}(?:[^.<]|(?:<[^<>]*>))*\.\)?//g;
|
||||
s/\s+\(\@pxref\{(?:[^\}]*)\}\)//g;
|
||||
s/;\s+\@pxref\{(?:[^\}]*)\}//g;
|
||||
s/\@noindent\s*//g;
|
||||
s/\@refill//g;
|
||||
s/\@gol//g;
|
||||
s/\@\*\s*\n?//g;
|
||||
|
||||
# @uref can take one, two, or three arguments, with different
|
||||
# semantics each time. @url and @email are just like @uref with
|
||||
# one argument, for our purposes.
|
||||
s/\@(?:uref|url|email)\{([^\},]*)\}/<B<$1>>/g;
|
||||
s/\@uref\{([^\},]*),([^\},]*)\}/$2 (C<$1>)/g;
|
||||
s/\@uref\{([^\},]*),([^\},]*),([^\},]*)\}/$3/g;
|
||||
|
||||
# Turn B<blah I<blah> blah> into B<blah> I<blah> B<blah> to
|
||||
# match Texinfo semantics of @emph inside @samp. Also handle @r
|
||||
# inside bold.
|
||||
s/</</g;
|
||||
s/>/>/g;
|
||||
1 while s/B<((?:[^<>]|I<[^<>]*>)*)R<([^>]*)>/B<$1>${2}B</g;
|
||||
1 while (s/B<([^<>]*)I<([^>]+)>/B<$1>I<$2>B</g);
|
||||
1 while (s/I<([^<>]*)B<([^>]+)>/I<$1>B<$2>I</g);
|
||||
s/[BI]<>//g;
|
||||
s/([BI])<(\s+)([^>]+)>/$2$1<$3>/g;
|
||||
s/([BI])<([^>]+?)(\s+)>/$1<$2>$3/g;
|
||||
|
||||
# Extract footnotes. This has to be done after all other
|
||||
# processing because otherwise the regexp will choke on formatting
|
||||
# inside @footnote.
|
||||
while (/\@footnote/g) {
|
||||
s/\@footnote\{([^\}]+)\}/[$fnno]/;
|
||||
add_footnote($1, $fnno);
|
||||
$fnno++;
|
||||
}
|
||||
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub unmunge
|
||||
{
|
||||
# Replace escaped symbols with their equivalents.
|
||||
local $_ = $_[0];
|
||||
|
||||
s/</E<lt>/g;
|
||||
s/>/E<gt>/g;
|
||||
s/{/\{/g;
|
||||
s/}/\}/g;
|
||||
s/&at;/\@/g;
|
||||
s/&/&/g;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub add_footnote
|
||||
{
|
||||
unless (exists $sects{FOOTNOTES}) {
|
||||
$sects{FOOTNOTES} = "\n=over 4\n\n";
|
||||
}
|
||||
|
||||
$sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++;
|
||||
$sects{FOOTNOTES} .= $_[0];
|
||||
$sects{FOOTNOTES} .= "\n\n";
|
||||
}
|
||||
|
||||
# stolen from Symbol.pm
|
||||
{
|
||||
my $genseq = 0;
|
||||
sub gensym
|
||||
{
|
||||
my $name = "GEN" . $genseq++;
|
||||
my $ref = \*{$name};
|
||||
delete $::{$name};
|
||||
return $ref;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user