Initial revision

CVS patchset: 5775
CVS date: 2002/10/15 14:53:45
This commit is contained in:
jbj 2002-10-15 14:53:45 +00:00
parent aab865e847
commit 4b652fc825
477 changed files with 150716 additions and 0 deletions

396
elfutils/ABOUT-NLS Normal file
View File

@ -0,0 +1,396 @@
Notes on the Free Translation Project
*************************************
Free software is going international! The Free Translation Project
is a way to get maintainers of free software, translators, and users all
together, so that will gradually become able to speak many languages.
A few packages already provide translations for their messages.
If you found this `ABOUT-NLS' file inside a distribution, you may
assume that the distributed package does use GNU `gettext' internally,
itself available at your nearest GNU archive site. But you do _not_
need to install GNU `gettext' prior to configuring, installing or using
this package with messages translated.
Installers will find here some useful hints. These notes also
explain how users should proceed for getting the programs to use the
available translations. They tell how people wanting to contribute and
work at translations should contact the appropriate team.
When reporting bugs in the `intl/' directory or bugs which may be
related to internationalization, you should tell about the version of
`gettext' which is used. The information can be found in the
`intl/VERSION' file, in internationalized packages.
Quick configuration advice
==========================
If you want to exploit the full power of internationalization, you
should configure it using
./configure --with-included-gettext
to force usage of internationalizing routines provided within this
package, despite the existence of internationalizing capabilities in the
operating system where this package is being installed. So far, only
the `gettext' implementation in the GNU C library version 2 provides as
many features (such as locale alias, message inheritance, automatic
charset conversion or plural form handling) as the implementation here.
It is also not possible to offer this additional functionality on top
of a `catgets' implementation. Future versions of GNU `gettext' will
very likely convey even more functionality. So it might be a good idea
to change to GNU `gettext' as soon as possible.
So you need _not_ provide this option if you are using GNU libc 2 or
you have installed a recent copy of the GNU gettext package with the
included `libintl'.
INSTALL Matters
===============
Some packages are "localizable" when properly installed; the
programs they contain can be made to speak your own native language.
Most such packages use GNU `gettext'. Other packages have their own
ways to internationalization, predating GNU `gettext'.
By default, this package will be installed to allow translation of
messages. It will automatically detect whether the system already
provides the GNU `gettext' functions. If not, the GNU `gettext' own
library will be used. This library is wholly contained within this
package, usually in the `intl/' subdirectory, so prior installation of
the GNU `gettext' package is _not_ required. Installers may use
special options at configuration time for changing the default
behaviour. The commands:
./configure --with-included-gettext
./configure --disable-nls
will respectively bypass any pre-existing `gettext' to use the
internationalizing routines provided within this package, or else,
_totally_ disable translation of messages.
When you already have GNU `gettext' installed on your system and run
configure without an option for your new package, `configure' will
probably detect the previously built and installed `libintl.a' file and
will decide to use this. This might be not what is desirable. You
should use the more recent version of the GNU `gettext' library. I.e.
if the file `intl/VERSION' shows that the library which comes with this
package is more recent, you should use
./configure --with-included-gettext
to prevent auto-detection.
The configuration process will not test for the `catgets' function
and therefore it will not be used. The reason is that even an
emulation of `gettext' on top of `catgets' could not provide all the
extensions of the GNU `gettext' library.
Internationalized packages have usually many `po/LL.po' files, where
LL gives an ISO 639 two-letter code identifying the language. Unless
translations have been forbidden at `configure' time by using the
`--disable-nls' switch, all available translations are installed
together with the package. However, the environment variable `LINGUAS'
may be set, prior to configuration, to limit the installed set.
`LINGUAS' should then contain a space separated list of two-letter
codes, stating which languages are allowed.
Using This Package
==================
As a user, if your language has been installed for this package, you
only have to set the `LANG' environment variable to the appropriate
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
and `CC' is an ISO 3166 two-letter country code. For example, let's
suppose that you speak German and live in Germany. At the shell
prompt, merely execute `setenv LANG de_DE' (in `csh'),
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
This can be done from your `.login' or `.profile' file, once and for
all.
You might think that the country code specification is redundant.
But in fact, some languages have dialects in different countries. For
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
country code serves to distinguish the dialects.
The locale naming convention of `LL_CC', with `LL' denoting the
language and `CC' denoting the country, is the one use on systems based
on GNU libc. On other systems, some variations of this scheme are
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
locales supported by your system for your country by running the command
`locale -a | grep '^LL''.
Not all programs have translations for all languages. By default, an
English message is shown in place of a nonexistent translation. If you
understand other languages, you can set up a priority list of languages.
This is done through a different environment variable, called
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
for the purpose of message handling, but you still need to have `LANG'
set to the primary language; this is required by other parts of the
system libraries. For example, some Swedish users who would rather
read translations in German than English for when Swedish is not
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
In the `LANGUAGE' environment variable, but not in the `LANG'
environment variable, `LL_CC' combinations can be abbreviated as `LL'
to denote the language's main dialect. For example, `de' is equivalent
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
(Portuguese as spoken in Portugal) in this context.
Translating Teams
=================
For the Free Translation Project to be a success, we need interested
people who like their own language and write it well, and who are also
able to synergize with other translators speaking the same language.
Each translation team has its own mailing list. The up-to-date list of
teams can be found at the Free Translation Project's homepage,
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
area.
If you'd like to volunteer to _work_ at translating messages, you
should become a member of the translating team for your own language.
The subscribing address is _not_ the same as the list itself, it has
`-request' appended. For example, speakers of Swedish can send a
message to `sv-request@li.org', having this message body:
subscribe
Keep in mind that team members are expected to participate
_actively_ in translations, or at solving translational difficulties,
rather than merely lurking around. If your team does not exist yet and
you want to start one, or if you are unsure about what to do or how to
get started, please write to `translation@iro.umontreal.ca' to reach the
coordinator for all translator teams.
The English team is special. It works at improving and uniformizing
the terminology in use. Proven linguistic skill are praised more than
programming skill, here.
Available Packages
==================
Languages are not equally supported in all packages. The following
matrix shows the current state of internationalization, as of March
2002. The matrix shows, in regard of each package, for which languages
PO files have been submitted to translation coordination, with a
translation percentage of at least 50%.
Ready PO files bg ca cs da de el en eo es et fi fr
+-------------------------------------+
a2ps | [] [] [] [] |
bash | [] [] [] [] |
bfd | [] [] |
binutils | [] [] |
bison | [] [] [] |
clisp | [] [] [] [] |
cpio | [] [] [] [] |
diffutils | [] [] [] [] [] [] |
enscript | [] [] |
error | [] [] |
fetchmail | () [] [] [] () |
fileutils | [] [] [] [] [] |
findutils | [] [] [] [] [] |
flex | [] [] [] [] |
gas | [] [] |
gawk | [] [] |
gcal | [] [] |
gcc | [] [] |
gettext | [] [] [] [] [] |
gnupg | [] [] [] [] [] [] |
gprof | [] [] |
grep | [] [] [] [] [] [] |
hello | [] [] [] [] [] [] [] [] |
id-utils | [] [] [] |
indent | [] [] [] [] [] |
jpilot | () [] [] [] |
jwhois | [] [] |
kbd | [] [] |
ld | [] [] |
libc | [] [] [] [] [] [] [] |
lilypond | [] [] |
lynx | [] [] [] [] |
m4 | [] [] [] [] [] |
make | [] [] [] [] |
mysecretdiary | [] [] |
nano | [] () [] [] [] [] |
nano_1_0 | [] () [] [] [] [] |
opcodes | [] [] [] |
parted | [] [] [] [] |
ptx | [] [] [] [] [] |
python | |
recode | [] [] [] [] [] [] |
sed | [] [] [] [] [] [] [] [] |
sh-utils | [] [] [] [] [] [] [] [] |
sharutils | [] [] [] [] [] [] |
sketch | () [] () |
soundtracker | [] [] [] |
sp | |
tar | [] [] [] [] [] [] |
texinfo | [] [] [] [] [] |
textutils | [] [] [] [] [] |
util-linux | [] [] [] [] |
vorbis-tools | |
wdiff | [] [] [] [] [] |
wget | [] [] [] [] [] [] [] [] |
+-------------------------------------+
bg ca cs da de el en eo es et fi fr
1 12 11 31 36 9 1 8 39 15 1 50
gl he hr hu id it ja ko lv nb nl nn
+-------------------------------------+
a2ps | () () [] |
bash | |
bfd | [] |
binutils | [] |
bison | [] [] |
clisp | [] |
cpio | [] [] [] |
diffutils | [] [] [] |
enscript | [] |
error | [] |
fetchmail | |
fileutils | [] [] [] |
findutils | [] [] [] [] [] [] |
flex | [] |
gas | |
gawk | [] |
gcal | |
gcc | |
gettext | [] |
gnupg | [] [] [] |
gprof | |
grep | [] |
hello | [] [] [] [] [] [] [] [] [] [] |
id-utils | [] |
indent | [] [] [] |
jpilot | () () |
jwhois | |
kbd | |
ld | |
libc | [] [] [] [] |
lilypond | [] [] |
lynx | [] [] |
m4 | [] [] [] [] |
make | [] [] [] [] |
mysecretdiary | |
nano | [] [] [] () [] () [] |
nano_1_0 | [] [] [] () [] () [] |
opcodes | [] |
parted | [] [] [] |
ptx | [] [] [] [] |
python | |
recode | [] [] [] |
sed | [] [] [] [] [] [] [] |
sh-utils | [] [] [] [] [] |
sharutils | [] [] [] |
sketch | () |
soundtracker | [] |
sp | |
tar | [] [] [] |
texinfo | [] [] |
textutils | [] [] |
util-linux | () [] |
vorbis-tools | |
wdiff | |
wget | [] [] [] [] [] |
+-------------------------------------+
gl he hr hu id it ja ko lv nb nl nn
19 7 0 4 6 11 22 9 1 8 19 4
no pl pt pt_BR ru sk sl sv tr uk zh_TW
+----------------------------------------+
a2ps | () () () [] [] [] () | 8
bash | | 4
bfd | [] [] | 5
binutils | [] | 4
bison | [] [] [] | 8
clisp | | 5
cpio | [] [] [] [] | 11
diffutils | [] [] [] [] [] | 14
enscript | [] [] [] | 6
error | [] [] [] | 6
fetchmail | () () [] | 4
fileutils | [] [] [] [] | 12
findutils | [] [] [] [] [] [] [] | 18
flex | [] [] [] | 8
gas | [] | 3
gawk | [] [] | 5
gcal | [] [] | 4
gcc | [] | 3
gettext | [] [] [] [] | 10
gnupg | [] [] [] | 12
gprof | [] [] | 4
grep | [] [] [] | 10
hello | [] [] [] [] [] [] [] | 25
id-utils | [] [] | 6
indent | [] [] [] [] | 12
jpilot | () () | 3
jwhois | () () [] | 3
kbd | [] [] | 4
ld | [] [] | 4
libc | [] [] [] [] [] [] | 17
lilypond | [] | 5
lynx | [] [] [] | 9
m4 | [] [] [] | 12
make | [] [] [] [] | 12
mysecretdiary | [] [] | 4
nano | () [] [] [] [] | 14
nano_1_0 | () [] [] [] | 13
opcodes | [] [] | 6
parted | [] [] [] | 10
ptx | [] [] [] [] [] [] | 15
python | | 0
recode | [] [] [] [] | 13
sed | [] [] [] [] [] [] | 21
sh-utils | [] [] [] [] [] [] [] [] [] | 22
sharutils | [] [] [] | 12
sketch | [] () | 3
soundtracker | [] | 5
sp | | 0
tar | [] [] [] [] [] [] [] | 16
texinfo | [] [] [] | 10
textutils | [] [] [] [] | 11
util-linux | [] [] [] | 8
vorbis-tools | [] | 1
wdiff | [] [] [] [] | 9
wget | [] [] [] [] [] [] [] | 20
+----------------------------------------+
35 teams no pl pt pt_BR ru sk sl sv tr uk zh_TW
55 domains 5 13 2 12 25 11 11 41 34 4 7 489
Some counters in the preceding matrix are higher than the number of
visible blocks let us expect. This is because a few extra PO files are
used for implementing regional variants of languages, or language
dialects.
For a PO file in the matrix above to be effective, the package to
which it applies should also have been internationalized and
distributed as such by its maintainer. There might be an observable
lag between the mere existence a PO file and its wide availability in a
distribution.
If March 2002 seems to be old, you may fetch a more recent copy of
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
matrix with full percentage details can be found at
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
Using `gettext' in new packages
===============================
If you are writing a freely available program and want to
internationalize it you are welcome to use GNU `gettext' in your
package. Of course you have to respect the GNU Library General Public
License which covers the use of the GNU `gettext' library. This means
in particular that even non-free programs can use `libintl' as a shared
library, whereas only free software can use `libintl' as a static
library or use modified versions of `libintl'.
Once the sources are changed appropriately and the setup can handle
to use of `gettext' the only thing missing are the translations. The
Free Translation Project is also available for packages which are not
developed inside the GNU project. Therefore the information given above
applies also for every other Free Software Project. Contact
`translation@iro.umontreal.ca' to make the `.pot' files available to
the translation teams.

2
elfutils/AUTHORS Normal file
View File

@ -0,0 +1,2 @@
For Now:
Ulrich Drepper.

340
elfutils/COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 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.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, 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 or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
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 give any other recipients of the Program a copy of this License
along with the Program.
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 Program or any portion
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
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 Program, 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 Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) 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; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 executable. However, as a
special exception, the source code 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.
If distribution of executable or 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 counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. 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 Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program 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 to
this License.
7. 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 Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program 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 Program.
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.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 Program
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 Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), 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 Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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 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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

8
elfutils/ChangeLog Normal file
View File

@ -0,0 +1,8 @@
2002-03-22 gettextize <bug-gnu-gettext@gnu.org>
* Makefile.am (SUBDIRS): Remove intl.
(EXTRA_DIST): Add config.rpath.
2000-08-25 Ulrich Drepper <drepper@redhat.com>
* The beginning.

182
elfutils/INSTALL Normal file
View File

@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

18
elfutils/Makefile.am Normal file
View File

@ -0,0 +1,18 @@
## Process this file with automake to create Makefile.in
AUTOMAKE_OPTIONS = 1.4 gnits
MAINT_CHARSET = latin1
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = m4 doc intl lib libltdl libelf libebl libdwarf libasm src \
libelf-po libebl-po libdwarf-po libasm-po po tests
EXTRA_DIST = config.rpath splint.rc
distcheck-hook:
chmod -R u+w $(distdir)
# Tell version 3.79 and up of GNU make to not build goals in this
# directory in parallel.
.NOTPARALLEL:

485
elfutils/Makefile.in Normal file
View File

@ -0,0 +1,485 @@
# Makefile.in generated by automake 1.6a from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@
AMTAR = @AMTAR@
AS = @AS@
AWK = @AWK@
BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIB = @HAVE_LIB@
INCLTDL = @INCLTDL@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTOBJEXT = @INSTOBJEXT@
INTLBISON = @INTLBISON@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIB = @LIB@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LOCALEDIR = @LOCALEDIR@
LTLIB = @LTLIB@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
MKINSTALLDIRS = @MKINSTALLDIRS@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
POSUB = @POSUB@
RANLIB = @RANLIB@
STRIP = @STRIP@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
am__include = @am__include@
am__quote = @am__quote@
install_sh = @install_sh@
AUTOMAKE_OPTIONS = 1.4 gnits
MAINT_CHARSET = latin1
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = m4 doc intl lib libltdl libelf libebl libdwarf libasm src \
libelf-po libebl-po libdwarf-po libasm-po po tests
EXTRA_DIST = config.rpath splint.rc
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = intl/Makefile
DIST_SOURCES =
RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \
uninstall-info-recursive all-recursive install-data-recursive \
install-exec-recursive installdirs-recursive install-recursive \
uninstall-recursive check-recursive installcheck-recursive
DIST_COMMON = README ABOUT-NLS AUTHORS COPYING ChangeLog INSTALL \
Makefile.am Makefile.in NEWS THANKS TODO aclocal.m4 \
config.guess config.h.in config.rpath config.sub configure \
configure.in depcomp install-sh ltmain.sh missing mkinstalldirs
DIST_SUBDIRS = $(SUBDIRS)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnits Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): configure.in m4/codeset.m4 m4/gettext.m4 m4/glibc21.m4 m4/iconv.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 m4/libtool.m4 m4/progtest.m4
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
touch $(srcdir)/config.h.in
distclean-hdr:
-rm -f config.h
intl/Makefile: $(top_builddir)/config.status $(top_srcdir)/intl/Makefile.in
cd $(top_builddir) && $(SHELL) ./config.status $@
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $(MAKEFLAGS); amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ETAGS = etags
ETAGSFLAGS =
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = .
distdir = $(PACKAGE)-$(VERSION)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
GZIP_ENV = --best
distcleancheck_listfiles = find . -type f -print
distdir: $(DISTFILES)
@if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" >/dev/null; \
then :; else \
echo "NEWS not updated; not releasing" 1>&2; \
exit 1; \
fi
$(am__remove_distdir)
mkdir $(distdir)
$(mkinstalldirs) $(distdir)/intl $(distdir)/libasm-po $(distdir)/libdwarf-po $(distdir)/libebl-po $(distdir)/libelf-po $(distdir)/po
@for file in $(DISTFILES); do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" \
distdir=../$(distdir)/$$subdir \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist dist-all: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
$(am__remove_distdir)
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \
&& $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
&& cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
--with-included-gettext \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& (test `find $$dc_install_base -type f -print | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
find $$dc_install_base -type f -print ; \
exit 1; } >&2 ) \
&& $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
&& rm -f $(distdir).tar.gz \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@echo "$(distdir).tar.gz is ready for distribution" | \
sed 'h;s/./=/g;p;x;p;x'
distcleancheck: distclean
if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile config.h
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f config.status config.cache config.log
distclean-am: clean-am distclean-generic distclean-hdr distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \
clean-generic clean-libtool clean-recursive dist dist-all \
dist-gzip distcheck distclean distclean-generic distclean-hdr \
distclean-libtool distclean-recursive distclean-tags \
distcleancheck distdir dvi dvi-am dvi-recursive info info-am \
info-recursive install install-am install-data install-data-am \
install-data-recursive install-exec install-exec-am \
install-exec-recursive install-info install-info-am \
install-info-recursive install-man install-recursive \
install-strip installcheck installcheck-am installdirs \
installdirs-am installdirs-recursive maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive mostlyclean \
mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
tags tags-recursive uninstall uninstall-am uninstall-info-am \
uninstall-info-recursive uninstall-recursive
distcheck-hook:
chmod -R u+w $(distdir)
# Tell version 3.79 and up of GNU make to not build goals in this
# directory in parallel.
.NOTPARALLEL:
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

376
elfutils/NEWS Normal file
View File

@ -0,0 +1,376 @@
Version 0.46:
libasm: rewrite to store Elf_Scn* instead of indeces
nm: finish many-section support
nm: use debug in to print file/line info in sysv format
libdwarf: fix a few bugs in DIE handling
Version 0.45:
libelf: major rewrite to keep Elf_Scn references valid until elf_end
Version 0.44:
libasm: Add support for bss, ABS, and COM sections.
libebl: ebl_section_name takes now two index arguments to distinguish
between special sections and extended sections
Version 0.43:
General: fix a few problem gcc 3.1 had with the code.
libelf: implement {gelf,elf32,elf64}_checksum
libelf: optimze DSO: fewer relocations, fewer PLTs
add msg_tst test
ld: use correct section header string table index; write correct index
add dependencies for *.sym files
Version 0.42:
libelf: add elf_getshnum and elf_getshstrndx
libebl: update section type name function
elflint: tons of fixes wrt large number of sections. New tests in this area.
Same amount of other bug fixes.
size, strip, nm: better support for large number of sections. Including
using correct section header string table
libasm: correctly create data structures for large number of sections
new tests asm-tst4 and asm-tst5 to check large number of sections
libasm: implement section group generation
elflint: more tests on section groups. Improve performance on existing
section group tests
Version 0.41:
ld: add undefined symbols to dynamic symbol table if --export-dynamic is
not given
ld: fix value of e_entry
Version 0.40:
elflint: print section names in error messages
elflint: mustn't warn about multiple DT_NULL
ld: don't emit all symbols if --export-dynamic is not given
ld: correct compute symbol address in output file (section index was off by 1)
ld: generate correct version info in dynsym without --export-dynamic and
in symtab
Version 0.39:
Fix check of various e_*size entries in elflint.
Handle text output in asm_newsym.
Finish checks in asm-tst3.
Version 0.38:
Update to autoconf 2.53, automake 1.6, gettext 0.11+.
Introduce *.sym files to restrict export from DSOs.
Use attribute_hidden and internal_function to optimize DSO code.
Add TLS definitions in elf.h and handle them in readelf.
Fix bug in verdef section generation in ld.
Add initial libasm code.
Version 0.37:
Implement better hash size optimization heuristic in ld. It uses a formula
taking number of tests into account.
Lots of small bug fixes.
Improve readelf output format. Respect various sh_link/sh_info values.
Correctly print versioning information for symbol tables.
Version 0.36:
Implement preprocessing of linker script. Recognize -z combreloc.
Version 0.35:
Implement -z ignore|record for ld.
Implement creating of .gnu.version_r and .gnu.version sections. The
.gnu.version does not yet contain correct info for defined and versioned
symbols (means .gnu.version_d is not yet implemented).
Implement gelf_update_* functions to create versioning data.
Version 0.34:
Add DT_RUNPATH/DT_RPATH entries to dynamic section. Create .plt and
.rel.plt sections (completely). Add support for all four PLT related
dynamic section entries. Add callback function for PLT creation.
More tests in elflint. Add support for very strict checking which for
now flags level 2 (deprecated features) usage.
Version 0.33:
Create dynamic symbol table, dynamic string table, and hash table to ld.
Add hash table histogram support to readelf.
Version 0.32:
more work on elflint
ld now creates the dynamic section and references it. Start adding entries
to dynamic section.
Version 0.31:
Start implementing elflint.
Version 0.30:
Fix handling of NOBITS sections in elf_getdata.
Start implementing generation of executables and DSOs in ld.
Generation of program header mostly done. Address computation done.
Extension of linker script syntax.
Various cleanups.
Implement section group handling in readelf.
Version 0.29:
Implement section groups. This involved a lot of code moving. The
new code is entirely untested since gas/gcc are currently not able to
create section groups. ld works fine on files without section groups.
Version 0.28:
Fix problem with adding more section in elf_newscn. The section pointers
for the data buffers wasn't adjusted.
Fix elf_getdata with nonzero second parameter. Correctly handle creation
of internal data buffer for machines without unaligned access.
Version 0.27:
Start adding support to selectively add sections. Includes support for
section groups.
Add --gc-sections/--no-gc-sections options.
Add general section merging support.
Fix a bug in section group support in strip.
Fix some potential problems with hash value in dynamic hash implementation.
Version 0.26:
section merging works in ld.
Version 0.25:
Actually create data structures from version map file and use it to hide
symbols in ld.
Implement -s -s for ld.
Version 0.24:
Improve relocation table output in readelf. Avoid some crashes.
Finish many section handling in readelf.
Finish: finish implementation of ld -r. At least some simple tests pass.
Version 0.23:
Fix a number of errors in ELF_C_WRITE handling.
Almost finished implementation of ld -r. The data sections are all copied.
Handling of symbol tables is missing.
Version 0.22:
Handle DSO and archive input files correctly if -r option is given.
Gracefully deal with no phdr in new file in libelf.
Fix various small error handling problems.
Don't mmap file for output unless the command says so.
Add code to create ELF section header table to ld finalize routines.
Version 0.21:
Fix some problems with recursive handling of archives in libelf.
Improve messages printed by nm.
Add symbol binding name handling to libebl. Fix section name handling in
libebl.
readelf and nm use more libebl functions.
Handle XINDEX correctly in nm and string.
Add first machine ld backend library (i386).
Use it. Recognize -r and --shared. Avoid using -lxxx parameters for -r.
Create ELF header in output file. Change mode of output file according to
output file type. Reorganize callback initialization in ld.
Version 0.20:
Fix some memory leaks in libelf.
Version 0.19:
Implement reading version script. Both inside linker scripts and via the
--version-script command line parameter. Uses the same code.
What remains to be done is to implement a data structure which allows
efficient matching against the version names to decide which pattern
matches.
Beginning of output generation and output writing functions.
Version 0.18:
Finish implementation for DSO input file handling. Implement rpath, runpath,
and LD_LIBRARY_PATH handling.
Version 0.17:
make handling of e_shnum overflow in libelf standard conforming
ld now actually can handle DSOs in linker scripts. Handling of DT_RUNPATH,
DT_RPATH, -rpath, -rpath-link still remains to be implemented.
fix handling of -L parameters. Make actual use of the default_paths element.
make re-definition of symbols in and from DSO compatible with existing linker
Version 0.16:
more work on assigning input sections to output sections.
Add gelf_xlatetof and gelf_xlatetom which were accidently left out.
Fix memory handling of section headers.
Version 0.15:
Add many-section support to ld. Add various new command line parameters.
Allow pagesize to be specified in linker script or on the command line.
Collect input sections in list for the output section according to the rules
specified in the linker script.
Version 0.14:
Fix some problems in the internal list handling which had the result
that we didn't look for some of the unresolved symbols.
Free some memory if we know we don't need it anymore.
Optimize the list of unresolved symbols. Throw out symbols which are
meanwhile resolved.
Version 0.13:
Got file reading correct now. The files are all read while parsing
the parameters. No creating of data structures to describe the linker
command line. The symbol table is built up while reading the files.
DSOs are handled now. -( -) handling is optimized.
Version 0.12:
Linker read linker scripts everywhere. Handles --whole-archive. Recognizes
--dynamic and --static. Collects defined and undefined symbols. Recognizes
conflicts.
libebl now defines functions to call the callbacks. Add generic name handling
in these new functions. Remove the code from readelf and call the new
functions.
Version 0.11:
Start of linker. Basic argument parsing, finding of input files,
linker script reading.
Version 0.10:
Implement dwarf_get_fde_n(), dwarf_get_abbrev(), dwarf_get_abbrev_tag(),
dwarf_get_abbrev_code(), dwarf_get_abbrev_children_flag(),
dwarf_get_abbrev_entry(), dwarf_get_fde_at_pc(), and tests for it.
Version 0.9:
Implement dwarf_get_fde_list_eh(), dwarf_get_cie_of_fde(),
dwarf_get_fde_range(), dwarf_get_cie_info(), dwarf_get_fde_instr_bytes(),
and tests for them.
Version 0.8:
Make handling of binaries in other byte order work and add tests for it.
Version 0.7:
Implement dwarf_get_aranges(), dwarf_get_arange(), dwarf_get_cu_die_offset(),
dwarf_get_arange_info(), and tests for them.
Version 0.6:
Implement dwarf_get_global(), dwarf_globname(), dwarf_global_die_offset(),
dwarf_global_cu_offset(), dwarf_global_name_offsets(), and tests for them
Version 0.5:
Implemented dwarf_srclines(), dwarf_srcfiles(), dwarf_linebeginstatement(),
dwarf_lineendsequence(), dwarf_lineno(), dwarf_lineaddr(), dwarf_lineoff(),
dwarf_linesrc(), dwarf_lineblock(), dwarf_lineprologueend(),
dwarf_lineepiloguebegin(), and tests for them.
Version 0.4:
Implemented dwarf_loclist().
Version 0.3:
Implemented dwarf_dieoffset(), dwarf_die_CU_offset(), dwarf_diename() and
tests.
Implemented dwarf_attrlist(), dwarf_hasattr(), dwarf_attr(), dwarf_lowpc(),
dwarf_highpc(), dwarf_bytesize(), dwarf_bitsize(), dwarf_bitoffset(),
dwarf_srclang(), dwarf_arrayorder(), dwarf_hasform(), dwarf_whatform(),
dwarf_whatattr(), dwarf_formref(), dwarf_global_formref(), dwarf_formaddr(),
dwarf_formflag(), dwarf_formudata(), dwarf_formsdata(), dwarf_formblock,
dwarf_formstring() and tests for them.
Version 0.2:
Implemented dwarf_offdie()), dwarf_tag(), dwarf_dieoffset(),
dwarf_die_CU_offset(), dwarf_diename() and tests for them.
Version 0.1:
First libdwarf functions work.
Version 0.0:
libelf and parts of libebl are done.

6
elfutils/README Normal file
View File

@ -0,0 +1,6 @@
Fundamental design decision:
- the sizes of external and internal types are assumed to be the same.
This leaves byte ordering aside. While assuming this the code can be
greatly simplified and speed increases. Since no change violating this
assumption is in sight this is believed to be a worthwhile optimization.

1
elfutils/THANKS Normal file
View File

@ -0,0 +1 @@
We'll see.

153
elfutils/TODO Normal file
View File

@ -0,0 +1,153 @@
ToDo list for elfutils -*-outline-*-
----------------------
Time-stamp: <02/06/28 10:07:28 drepper>
* libelf:
** verify section
Currently the elf_update function trusts the user blindly if the
ELF_F_LAYOUT flag is set. This is OK if the data is prepared by a
ELF_C_NULL call but not if the user prepared the data herself
** break out archive handling from elf_begin
The handling of archives (especially of the symbol tables) must be
broken out of elf_begin. There are several different forms of
archives and only when having the archive handling separately this
remains maintainable.
* libdwarf
** Should we do more error checking?
Most functions don't check whether they get a NULL value passed for
a pointer argument. It could be argued that this is OK since it's
a bug inthe program. But perhaps one could catch the case and return
an error which would allow the program using libdwarf to have fewer
places with error checking.
** More memory access checks needed
All accesses to the debug sections should make sure the offsets are
valid. This is currently especially a problem with leb128 accesses.
** Low level macro information operations
in 5.11.3 are not implemented. gcc currently does not emit this
information so I cannot test it.
** Rename dwarf_getabbrev
** dwarf_loclist()
This function and its interface seem to be misdesigned. The specification
is unclear and its changed between v2 and v2.1. Other implementation
implement even different behavior.
* nm:
** add demangler support
Use demangler from libiberty.
** add support to read debugging symbols
after libdwarf is implemented use it to read debugging information.
sysv format needs output of line number
* strip:
** support SHT_SYMTAB_SHNDX
renumbering
should be removed if not needed anymore
follow and update cross-references in SHT_SYMTAB_SHNDX as well.
* ld:
** sanity check .rel sh_info content
the sh_info of all .rel sections with the same name must point to
sections which also have the same name
** use ld.so.conf
to locate shared libraries aslo use /etc/ld.so.conf
** handle object files for different architectures
ld.so is expected to ignore object files for different architectures and
continue looking for a matching file (e.g., ignore 32-bit binaries on
64-bit platforms and vice versa). We probably need the same in ld.
** reuse after elf_end
Some files are closed using elf_end. They are removed from memory only
if no reference is left (especially for archives this is a problem).
The old mapping should be reused in that case. The problem is worse
for files which are not mapped read-only (archives again).
* elflint
** additional checks
1st GOT entry == _DYNAMIC
if TEXTREL check whether any relocation touches RO segment
if TEXTREL not set check that no relocation touches RO segment
check versioning info:
always BASE in verdef
sh_size/sh_entsize matches last offset != 0
check whether any relocation is for a merge-able section
* mcs
Sun has it. Can modify sections which are not in segments.
-a string
Append string to the comment section of the ELF object
files. If string contains embedded blanks, it must be
enclosed in quotation marks.
-c Compress the contents of the comment section of the
ELF object files. All duplicate entries are removed.
The ordering of the remaining entries is not dis-
turbed.
-d Delete the contents of the comment section from the
ELF object files. The section header for the comment
section is also removed.
-n name
Specify the name of the comment section to access if
other than .comment. By default, mcs deals with the
section named .comment. This option can be used to
specify another section. mcs can take multiple -n
options to allow for specification of multiple sec-
tion comments.
-p Print the contents of the comment section on the stan-
dard output. Each section printed is tagged by the
name of the file from which it was extracted, using
the format file[member_name]: for archive files and
file: for other files.
-V Print on standard error the version number of mcs.
Local Variables:
eval:(hide-body)
End:

5958
elfutils/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

1317
elfutils/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

306
elfutils/config.h.in Normal file
View File

@ -0,0 +1,306 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `feof_unlocked' function. */
#undef HAVE_FEOF_UNLOCKED
/* Define to 1 if you have the `fgets_unlocked' function. */
#undef HAVE_FGETS_UNLOCKED
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* Define to 1 if you have the `getc_unlocked' function. */
#undef HAVE_GETC_UNLOCKED
/* Define to 1 if you have the `getegid' function. */
#undef HAVE_GETEGID
/* Define to 1 if you have the `geteuid' function. */
#undef HAVE_GETEUID
/* Define to 1 if you have the `getgid' function. */
#undef HAVE_GETGID
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the `munmap' function. */
#undef HAVE_MUNMAP
/* Define to 1 if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `stpcpy' function. */
#undef HAVE_STPCPY
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `tsearch' function. */
#undef HAVE_TSEARCH
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `__argz_count' function. */
#undef HAVE___ARGZ_COUNT
/* Define to 1 if you have the `__argz_next' function. */
#undef HAVE___ARGZ_NEXT
/* Define to 1 if you have the `__argz_stringify' function. */
#undef HAVE___ARGZ_STRINGIFY
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Directory to place translation files in. */
#undef LOCALEDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#undef inline
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Eventually we will allow multi-threaded applications to use the
libraries. Therefore we will add the necessary locking although
the macros used expand to nothing for now. */
#define lock_lock(lock)
#define rwlock_define(class,name) class int name
#define rwlock_init(lock)
#define rwlock_fini(lock)
#define rwlock_rdlock(lock)
#define rwlock_wrlock(lock)
#define rwlock_unlock(lock)
#define tls_key_t void *
#define key_create(keyp, freefct) ((void) (keyp), (void) (freefct), 1)
#define getspecific(key) key
#define setspecific(key,val) key = val
#define once_define(class,name) class int name
#define once_execute(name,fct) \
do { \
if (name == 0) \
fct (); \
name = 1; \
} while (0)
/* gettext helper macro. */
#define N_(Str) Str
/* Compiler-specific definitions. */
#define strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
#ifdef __i386__
# define internal_function \
__attribute__ ((regparm (3), stdcall, visibility ("internal")))
# define internal_strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name), stdcall, visibility ("internal")));
#else
# define internal_function \
__attribute__ ((visibility ("internal")))
# define internal_strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name), visibility ("hiden")));
#endif
#define attribute_hidden \
__attribute__ ((visibility ("hidden")))
/* Define ALLOW_UNALIGNED if the architecture allows operations on
unaligned memory locations. */
#ifdef __i386__
# define ALLOW_UNALIGNED 1
#else
# undef ALLOW_UNALIGNED
#endif
#ifdef __GNUC__
# define unlikely(expr) __builtin_expect (expr, 0)
# define likely(expr) __builtin_expect (expr, 1)
#else
# define unlikely(expr) (expr)
# define likely(expr) (expr)
#endif
#if __STDC_VERSION__ >= 199901L
# define flexarr_size /* empty */
#else
# define flexarr_size 0
#endif
/* Calling conventions. */
#ifdef __i386__
# define CALLING_CONVENTION regparm (3), stdcall
# define AND_CALLING_CONVENTION , regparm (3), stdcall
#else
# define CALLING_CONVENTION
# define AND_CALLING_CONVENTION
#endif
/* Avoid PLT entries. */
#if defined __PIC__ && defined __GNUC__
# define INTUSE(name) _INTUSE(name)
# define _INTUSE(name) __##name##_internal
# define INTDEF(name) _INTDEF(name)
# define _INTDEF(name) \
extern __typeof__ (name) __##name##_internal __attribute__ ((alias (#name)));
#else
# define INTUSE(name) name
# define INTDEF(name) /* empty */
#endif

513
elfutils/config.rpath Executable file
View File

@ -0,0 +1,513 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2002 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# 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 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.
#
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# All known linkers require a `.a' archive for static linking (except M$VC,
# which needs '.lib').
libext=a
shlibext=
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix3* | aix4* | aix5*)
wl='-Wl,'
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6*)
wl='-Wl,'
;;
linux*)
echo '__INTEL_COMPILER' > conftest.$ac_ext
if $CC -E conftest.$ac_ext >/dev/null | grep __INTEL_COMPILER >/dev/null
then
:
else
# Intel icc
wl='-Qoption,ld,'
fi
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
if test "x$host_vendor" = xsni; then
wl='-LD'
else
wl='-Wl,'
fi
;;
esac
fi
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX, the GNU linker is very broken
ld_shlibs=no
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we can use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
;;
solaris* | sysv5*)
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
hardcode_direct=yes
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
esac
fi
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib'
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
hardcode_direct=yes
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9* | hpux10* | hpux11*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
hardcode_minus_L=yes # Not in the search PATH, but as the default
# location of the library.
;;
irix5* | irix6*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
sco3.2v5*)
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
if test "x$host_vendor" = xsno; then
hardcode_direct=yes # is this really true???
else
hardcode_direct=no # Motorola manual says yes, but my tests say they lie
fi
;;
sysv4.3*)
;;
sysv5*)
hardcode_libdir_flag_spec=
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4.2uw2*)
hardcode_direct=yes
hardcode_minus_L=no
;;
sysv5uw7* | unixware7*)
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
libname_spec='lib$name'
sys_lib_dlsearch_path_spec="/lib /usr/lib"
sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
case "$host_os" in
aix3*)
shlibext=so
;;
aix4* | aix5*)
shlibext=so
;;
amigaos*)
shlibext=ixlibrary
;;
beos*)
shlibext=so
;;
bsdi4*)
shlibext=so
sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
;;
cygwin* | mingw* | pw32*)
case $GCC,$host_os in
yes,cygwin*)
shlibext=dll.a
;;
yes,mingw*)
shlibext=dll
sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"`
;;
yes,pw32*)
shlibext=dll
;;
*)
shlibext=dll
;;
esac
;;
darwin* | rhapsody*)
shlibext=dylib
;;
freebsd1*)
;;
freebsd*)
shlibext=so
;;
gnu*)
shlibext=so
;;
hpux9* | hpux10* | hpux11*)
shlibext=sl
;;
irix5* | irix6*)
shlibext=so
case "$host_os" in
irix5*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 ") libsuff= shlibsuff= ;;
*-n32|*"-n32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
;;
linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*)
;;
linux-gnu*)
shlibext=so
;;
netbsd*)
shlibext=so
;;
newsos6)
shlibext=so
;;
openbsd*)
shlibext=so
;;
os2*)
libname_spec='$name'
shlibext=dll
;;
osf3* | osf4* | osf5*)
shlibext=so
sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
;;
sco3.2v5*)
shlibext=so
;;
solaris*)
shlibext=so
;;
sunos4*)
shlibext=so
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
shlibext=so
case "$host_vendor" in
motorola)
sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
;;
esac
;;
uts4*)
shlibext=so
;;
dgux*)
shlibext=so
;;
sysv4*MP*)
if test -d /usr/nec; then
shlibext=so
fi
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_sys_lib_search_path_spec=`echo "X$sys_lib_search_path_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_sys_lib_dlsearch_path_spec=`echo "X$sys_lib_dlsearch_path_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
# Compile-time system search path for libraries
sys_lib_search_path_spec="$escaped_sys_lib_search_path_spec"
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec="$escaped_sys_lib_dlsearch_path_spec"
EOF

1411
elfutils/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

12718
elfutils/configure vendored Executable file

File diff suppressed because it is too large Load Diff

138
elfutils/configure.in Normal file
View File

@ -0,0 +1,138 @@
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
AC_INIT(src/readelf.c)
AM_CONFIG_HEADER(config.h)
AC_PREREQ(2.53) dnl Minimum Autoconf version required.
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([elfutils], [0.46])
ALL_LINGUAS=
AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AM_GNU_GETTEXT
AC_LIBLTDL_CONVENIENCE
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
AC_CONFIG_SUBDIRS(libltdl)
AC_PROG_YACC
AM_PROG_LEX
LOCALEDIR=$datadir
AC_SUBST(LOCALEDIR)
AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
AH_TEMPLATE([LOCALEDIR], [Directory to place translation files in.])
AH_BOTTOM([
/* Eventually we will allow multi-threaded applications to use the
libraries. Therefore we will add the necessary locking although
the macros used expand to nothing for now. */
#define lock_lock(lock)
#define rwlock_define(class,name) class int name
#define rwlock_init(lock)
#define rwlock_fini(lock)
#define rwlock_rdlock(lock)
#define rwlock_wrlock(lock)
#define rwlock_unlock(lock)
#define tls_key_t void *
#define key_create(keyp, freefct) ((void) (keyp), (void) (freefct), 1)
#define getspecific(key) key
#define setspecific(key,val) key = val
#define once_define(class,name) class int name
#define once_execute(name,fct) \
do { \
if (name == 0) \
fct (); \
name = 1; \
} while (0)
/* gettext helper macro. */
#define N_(Str) Str
/* Compiler-specific definitions. */
#define strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
#ifdef __i386__
# define internal_function \
__attribute__ ((regparm (3), stdcall, visibility ("internal")))
# define internal_strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name), stdcall, visibility ("internal")));
#else
# define internal_function \
__attribute__ ((visibility ("internal")))
# define internal_strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name), visibility ("hiden")));
#endif
#define attribute_hidden \
__attribute__ ((visibility ("hidden")))
/* Define ALLOW_UNALIGNED if the architecture allows operations on
unaligned memory locations. */
#ifdef __i386__
# define ALLOW_UNALIGNED 1
#else
# undef ALLOW_UNALIGNED
#endif
#ifdef __GNUC__
# define unlikely(expr) __builtin_expect (expr, 0)
# define likely(expr) __builtin_expect (expr, 1)
#else
# define unlikely(expr) (expr)
# define likely(expr) (expr)
#endif
#if __STDC_VERSION__ >= 199901L
# define flexarr_size /* empty */
#else
# define flexarr_size 0
#endif
/* Calling conventions. */
#ifdef __i386__
# define CALLING_CONVENTION regparm (3), stdcall
# define AND_CALLING_CONVENTION , regparm (3), stdcall
#else
# define CALLING_CONVENTION
# define AND_CALLING_CONVENTION
#endif
/* Avoid PLT entries. */
#if defined __PIC__ && defined __GNUC__
# define INTUSE(name) _INTUSE(name)
# define _INTUSE(name) __##name##_internal
# define INTDEF(name) _INTDEF(name)
# define _INTDEF(name) \
extern __typeof__ (name) __##name##_internal __attribute__ ((alias (#name)));
#else
# define INTUSE(name) name
# define INTDEF(name) /* empty */
#endif
])
dnl This test must come as early as possible after the compiler configuration
dnl tests, because the choice of the file model can (in principle) affect
dnl whether functions and headers are available, whether they work, etc.
AC_SYS_LARGEFILE
AC_OUTPUT([Makefile
m4/Makefile
doc/Makefile
lib/Makefile
intl/Makefile
libelf/Makefile
libebl/Makefile
libdwarf/Makefile
libasm/Makefile
src/Makefile
libelf-po/Makefile.in
libebl-po/Makefile.in
libdwarf-po/Makefile.in
libasm-po/Makefile.in
po/Makefile.in
tests/Makefile])

436
elfutils/depcomp Executable file
View File

@ -0,0 +1,436 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
# Copyright 1999, 2000 Free Software Foundation, Inc.
# 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, 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.
# 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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# `libtool' can also be set to `yes' or `no'.
if test -z "$depfile"; then
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
dir=`echo "$object" | sed 's,/.*$,/,'`
if test "$dir" = "$object"; then
dir=
fi
# FIXME: should be _deps on DOS.
depfile="$dir.deps/$base"
fi
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. This file always lives in the current directory.
# Also, the AIX compiler puts `$object:' at the start of each line;
# $object doesn't have directory information.
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
outname="$stripped.o"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
base=`echo "$object" | sed -e 's/\.o$/.d/' -e 's/\.lo$/.d/'`
tmpdepfile1="$base.o.d"
tmpdepfile2="$base.d"
if test "$libtool" = yes; then
"$@" -Wc,-MD
else
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
else
tmpdepfile="$tmpdepfile2"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a space and a tab in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
test -z "$dashmflag" && dashmflag=-M
( IFS=" "
case " $* " in
*" --mode=compile "*) # this is libtool, let us make it quiet
for arg
do # cycle over the arguments
case "$arg" in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
# X makedepend
(
shift
cleared=no
for arg in "$@"; do
case $cleared in no)
set ""; shift
cleared=yes
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift;;
-*)
;;
*)
set fnord "$@" "$arg"; shift;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the proprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
( IFS=" "
case " $* " in
*" --mode=compile "*)
for arg
do # cycle over the arguments
case $arg in
"--mode=compile")
# insert --quiet before "--mode=compile"
set fnord "$@" --quiet
shift # fnord
;;
esac
set fnord "$@" "$arg"
shift # fnord
shift # "$arg"
done
;;
esac
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
) &
proc=$!
"$@"
stat=$?
wait "$proc"
if test "$stat" != 0; then exit $stat; fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0

18
elfutils/doc/Makefile.am Normal file
View File

@ -0,0 +1,18 @@
## Process this file with automake to create Makefile.in
AUTOMAKE_OPTIONS = 1.4 gnits
EXTRA_DIST = new-bu.sgml
CLEANFILES = new-bu.dvi
# We need only a few special rules to generate the various output formats
# from the SGML sources.
.PHONY: dvi pdf html
dvi: $(srcdir)new-bu.dvi
pdf: $(srcdir)new-bu.pdf
$(srcdir)%.dvi: %.sgml
db2dvi $^
$(srcdir)%.pdf: %.sgml
db2pdf $^

261
elfutils/doc/Makefile.in Normal file
View File

@ -0,0 +1,261 @@
# Makefile.in generated by automake 1.6a from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@
AMTAR = @AMTAR@
AS = @AS@
AWK = @AWK@
BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIB = @HAVE_LIB@
INCLTDL = @INCLTDL@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTOBJEXT = @INSTOBJEXT@
INTLBISON = @INTLBISON@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIB = @LIB@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LOCALEDIR = @LOCALEDIR@
LTLIB = @LTLIB@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
MKINSTALLDIRS = @MKINSTALLDIRS@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
POSUB = @POSUB@
RANLIB = @RANLIB@
STRIP = @STRIP@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
am__include = @am__include@
am__quote = @am__quote@
install_sh = @install_sh@
AUTOMAKE_OPTIONS = 1.4 gnits
EXTRA_DIST = new-bu.sgml
CLEANFILES = new-bu.dvi
subdir = doc
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DIST_COMMON = Makefile.am Makefile.in
all: all-am
.SUFFIXES:
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnits doc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
uninstall-info-am:
tags: TAGS
TAGS:
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
dvi-am:
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
uninstall-am: uninstall-info-am
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool uninstall uninstall-am uninstall-info-am
# We need only a few special rules to generate the various output formats
# from the SGML sources.
.PHONY: dvi pdf html
dvi: $(srcdir)new-bu.dvi
pdf: $(srcdir)new-bu.pdf
$(srcdir)%.dvi: %.sgml
db2dvi $^
$(srcdir)%.pdf: %.sgml
db2pdf $^
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

412
elfutils/doc/new-bu.sgml Normal file
View File

@ -0,0 +1,412 @@
<!doctype book PUBLIC "-//OASIS//DTD DocBook V4.1//EN"[
<!ENTITY package "<filename>new-bu</filename>">
]>
<book>
<title>New Binutils User's and Reference Manual</title>
<chapter>
<title><filename>libelf</filename> <acronym>ABI</acronym></title>
<simpara>The <acronym>ABI</acronym> of the
<filename>libelf</filename> implemented in the &package; package
is following that of Sun's implementation which in turn in derived
from the original SysVr4 implementation. There are some
extensions over Sun's versions, though, which makes it impossible
to replace this implementation with Sun's.</simpara>
<beginpage>
<refentry xreflabel="Elf_Data" id="ElfUData">
<refnamediv>
<refname>Elf_Data</refname>
<refpurpose>Descriptor for Data Buffer</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
#include &lt;libelf.h&gt;
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<simpara>The <structname>Elf_Data</structname> structure is as
a descriptor for a data buffer associated with a section.
Every data buffer is associated with a specific section (see
<!-- xref --><structname>Elf_Scn</structname>).</simpara>
<simpara>A data buffer is created when reading a file. In
this case only a single buffer is present in the section. The
user can add as many sections as wanted to a section and they
can be retrieved using the <function>elf_getdata</function>
and <function>elf_rawdata</function> functions.<!-- xref
--></simpara>
<simpara>The <structname>Elf_Data</structname> structure
contains the following members:</simpara>
<programlisting>
void *d_buf
Elf_Type d_type
size_t d_size
off_t d_off
size_t d_align
unsigned int d_version
</programlisting>
<simpara>All these members can be modified directly by the
user. They can be used to resize a section, to change its
content or type, and many things more. This is also true for
the data read from a file. The meaning of the members is as
follows:</simpara>
<variablelist>
<varlistentry>
<term><structfield>d_buf</structfield></term>
<listitem>
<simpara>The <structfield>d_buf</structfield> member is
the pointer to the buffer with the actual data. When
the ELF file was read from a file the first and only
data buffer of a section is allocated by the
<filename>libelf</filename> library. The user should
not try to resize or free this buffer. When the user
adds a new data buffer to a section the associated
memory block is normally allocated by the user. It is
important that the buffer must have a lifetime at least
until the ELF file is closed entirely (important when
the buffer is allocated on the stack). If the buffer is
not allocated on the stack it is the user's
responsibility to free the buffer after it is not used
anymore. The <structfield>d_buf</structfield> member
can contain a null pointer if the data buffer is
empty.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><structfield>d_type</structfield></term>
<listitem>
<simpara>The <structfield>d_type</structfield>
determines how the data of the buffer is interpreted.
This type is determined from the section type and must
be the same for all data buffers for a section. See
<!-- xref --><type>Elf_Type</type> for more information.
The <function><link linkend="elfUgetdata"
endterm="elfUgetdata.refname"></link></function>
function uses this information to convert the data of
the buffer between the external form and the form
represented to the user and back if necessary.</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
<beginpage>
<refentry id="elfUgetdata">
<refnamediv>
<refname id="elfUgetdata.refname">elf_getdata</refname>
<refpurpose>Get washed data of section</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>
#include &lt;libelf.h&gt;
</funcsynopsisinfo>
<funcprototype>
<funcdef>Elf_Data *<function>elf_getdata</function></funcdef>
<paramdef>Elf_Scn *<parameter>scn</parameter></paramdef>
<paramdef>Elf_Data *<parameter>data</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<simpara>The <function>elf_getdata</function> function allows
to retriece the data buffers of the section
<parameter>scn</parameter>. There can be more than one buffer
if the user explicitly added them. When a file is read the
<filename>libelf</filename> library creates exactly one data
buffer.</simpara>
<simpara>The first buffer in the list can be obtained by
passing a null pointer in the parameter
<parameter>data</parameter>. To get the next data buffer the
previously returned value must be passed in the
<parameter>data</parameter> parameter. If there is no more
buffer left in the list a null pointer is returned.</simpara>
<simpara>If the <parameter>data</parameter> parameter is not a
null pointer it must be a descriptor with for a buffer
associated with the section <parameter>scn</parameter>. If
this is not the case a null pointer is returned. To
facilitate error handling <function>elf_getdata</function>
also returns a null pointer if the <parameter>scn</parameter>
parameter is a null pointer.</simpara>
</refsect1>
</refentry>
<refentry>
<refnamediv>
<refname id="elfUupdate.refname">elf_update</refname>
<refpurpose>update an ELF descriptor</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>
#include &lt;libelf.h&gt;
</funcsynopsisinfo>
<funcprototype>
<funcdef>off_t <function>elf_update</function></funcdef>
<paramdef>Elf *<parameter>elf</parameter></paramdef>
<paramdef>Elf_Cmd <parameter>cmd</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<simpara>The user is responsible for filling in the following
fields in the named data structures:</simpara>
<table>
<title>Fields not set by <function>elf_update</function></title>
<tgroup cols="3">
<colspec colwidth="90pt">
<colspec colwidth="110pt">
<thead>
<row>
<entry>Data Structure</entry>
<entry>Member</entry>
<entry>Exception</entry>
</row>
</thead>
<tbody>
<row>
<entry morerows="8"><type>Elfxx_Ehdr</type></entry>
<entry>e_ident[EI_DATA]</entry>
<entry>see below</entry>
</row>
<row>
<entry></entry>
<entry>e_type</entry>
<!-- <entry morerows="1"></entry> -->
<entry></entry>
</row>
<row>
<entry></entry>
<entry>e_machine</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>e_version</entry>
<entry>see below</entry>
</row>
<row>
<entry></entry>
<entry>e_entry</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>e_phoff</entry>
<entry>if <symbol>ELF_F_LAYOUT</symbol> is used</entry>
</row>
<row>
<entry></entry>
<entry>e_shoff</entry>
<entry>if <symbol>ELF_F_LAYOUT</symbol> is used</entry>
</row>
<row>
<entry></entry>
<entry>e_flags</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>e_shstrndx</entry>
<entry></entry>
</row>
<row>
<entry morerows="7">Elfxx_Phdr</entry>
<entry>p_type</entry>
<entry morerows="7"></entry>
</row>
<row>
<entry></entry>
<entry>p_offset</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>p_vaddr</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>p_paddr</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>p_filesz</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>p_memsz</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>p_flags</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>p_align</entry>
<entry></entry>
</row>
<row>
<entry morerows="9">Elfxx_Shdr</entry>
<entry>sh_name</entry>
<entry morerows="3"></entry>
</row>
<row>
<entry></entry>
<entry>sh_type</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>sh_flags</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>sh_addr</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>sh_offset</entry>
<entry>if <symbol>ELF_F_LAYOUT</symbol> is used</entry>
</row>
<row>
<entry></entry>
<entry>sh_size</entry>
<entry>if <symbol>ELF_F_LAYOUT</symbol> is used</entry>
</row>
<row>
<entry></entry>
<entry>sh_link</entry>
<!-- <entry morerows="1"></entry> -->
<entry></entry>
</row>
<row>
<entry></entry>
<entry>sh_info</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>sh_addralign</entry>
<entry>if <symbol>ELF_F_LAYOUT</symbol> is used</entry>
</row>
<row>
<entry></entry>
<entry>sh_entsize</entry>
<entry></entry>
</row>
<row>
<entry morerows="5">Elf_Data</entry>
<entry>d_buf</entry>
<entry morerows="2"></entry>
</row>
<row>
<entry></entry>
<entry>d_type</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>d_size</entry>
<entry></entry>
</row>
<row>
<entry></entry>
<entry>d_off</entry>
<entry>if <symbol>ELF_F_LAYOUT</symbol> is used</entry>
</row>
<row>
<entry></entry>
<entry>d_align</entry>
<!-- <entry morerows="1"></entry> -->
<entry></entry>
</row>
<row>
<entry></entry>
<entry>d_version</entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
<simpara>Two fields of the ELF header are handled in a special
way:</simpara>
<variablelist>
<varlistentry>
<term>e_version</term>
<listitem>
<simpara>The user can set this field to the vvalue for
the version to be used. It is an error if the library
cannot handle this version. If the field contains the
value <symbol>EV_NONE</symbol> the library will fill in
its own internal version.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>e_ident[EI_DATA]</term>
<listitem>
<simpara>The user should fill in the byte ordering for
the file. If the value of the field is
<symbol>ELFDATANONE</symbol> the library replaces it
with the native byte ordering for the machine.</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
</chapter>
<chapter>
<title><filename>libelf</filename> Internals</title>
<simpara>Since the binary format handling tools need constant
attention since there are always new machines and varients
therefore coming out it is important to have the implementation
weel documented. Only this way extensions can be made in the
right places and the mistakes of the past avoided.</simpara>
</chapter>
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omitag:nil
sgml-shorttag:t
End:
-->

251
elfutils/install-sh Executable file
View File

@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
:
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
:
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
:
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
:
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
:
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
:
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

4
elfutils/intl/ChangeLog Normal file
View File

@ -0,0 +1,4 @@
2002-03-12 GNU <bug-gnu-gettext@gnu.org>
* Version 0.11.1 released.

337
elfutils/intl/Makefile.in Normal file
View File

@ -0,0 +1,337 @@
# Makefile for directory with message catalog handling in GNU NLS Utilities.
# Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
PACKAGE = @PACKAGE@
VERSION = @VERSION@
SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
transform = @program_transform_name@
libdir = @libdir@
includedir = @includedir@
datadir = @datadir@
localedir = $(datadir)/locale
gettextsrcdir = $(datadir)/gettext/intl
aliaspath = $(localedir)
subdir = intl
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = @MKINSTALLDIRS@
mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac`
l = @INTL_LIBTOOL_SUFFIX_PREFIX@
AR = ar
CC = @CC@
LIBTOOL = @LIBTOOL@
RANLIB = @RANLIB@
YACC = @INTLBISON@ -y -d
YFLAGS = --name-prefix=__gettext
DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
-DLIBDIR=\"$(libdir)\" -DIN_LIBINTL @DEFS@
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
HEADERS = $(COMHDRS) libgnuintl.h loadinfo.h
COMHDRS = gmo.h gettextP.h hash-string.h plural-exp.h eval-plural.h os2compat.h
SOURCES = $(COMSRCS) intl-compat.c
COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \
finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \
explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y \
plural-exp.c localcharset.c localename.c osdep.c os2compat.c
OBJECTS = @INTLOBJS@ bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \
finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \
explodename.$lo dcigettext.$lo dcngettext.$lo dngettext.$lo ngettext.$lo \
plural.$lo plural-exp.$lo localcharset.$lo localename.$lo osdep.$lo
GETTOBJS = intl-compat.$lo
DISTFILES.common = Makefile.in \
config.charset locale.alias ref-add.sin ref-del.sin $(HEADERS) $(SOURCES)
DISTFILES.generated = plural.c
DISTFILES.normal = VERSION
DISTFILES.gettext = COPYING.LIB-2.0 COPYING.LIB-2.1 libintl.glibc
DISTFILES.obsolete = xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c \
COPYING.LIB-2 gettext.h libgettext.h plural-eval.c
# Libtool's library version information for libintl.
# Before making a gettext release, the gettext maintainer must change this
# according to the libtool documentation, section "Library interface versions".
# Maintainers of other packages that include the intl directory must *not*
# change these values.
LTV_CURRENT=2
LTV_REVISION=0
LTV_AGE=0
.SUFFIXES:
.SUFFIXES: .c .y .o .lo .sin .sed
.c.o:
$(COMPILE) $<
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) $<
.y.c:
$(YACC) $(YFLAGS) --output $@ $<
rm -f $*.h
.sin.sed:
sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > t-$@
mv t-$@ $@
INCLUDES = -I.. -I. -I$(top_srcdir)/intl
all: all-@USE_INCLUDED_LIBINTL@
all-yes: libintl.$la libintl.h charset.alias ref-add.sed ref-del.sed
all-no: all-no-@BUILD_INCLUDED_LIBINTL@
all-no-yes: libgnuintl.$la
all-no-no:
libintl.a libgnuintl.a: $(OBJECTS)
rm -f $@
$(AR) cru $@ $(OBJECTS)
$(RANLIB) $@
libintl.la libgnuintl.la: $(OBJECTS)
$(LIBTOOL) --mode=link \
$(CC) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) $(LDFLAGS) -o $@ \
$(OBJECTS) @LTLIBICONV@ -lc \
-version-info $(LTV_CURRENT):$(LTV_REVISION):$(LTV_AGE) \
-rpath $(libdir) \
-no-undefined
libintl.h: libgnuintl.h
cp $(srcdir)/libgnuintl.h libintl.h
charset.alias: config.charset
$(SHELL) $(srcdir)/config.charset '@host@' > t-$@
mv t-$@ $@
check: all
# This installation goal is only used in GNU gettext. Packages which
# only use the library should use install instead.
# We must not install the libintl.h/libintl.a files if we are on a
# system which has the GNU gettext() function in its C library or in a
# separate library.
# If you want to use the one which comes with this version of the
# package, you have to use `configure --with-included-gettext'.
install: install-exec install-data
install-exec: all
if test "$(PACKAGE)" = "gettext" \
&& test '@INTLOBJS@' = '$(GETTOBJS)'; then \
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
$(INSTALL_DATA) libintl.h $(DESTDIR)$(includedir)/libintl.h; \
$(LIBTOOL) --mode=install \
$(INSTALL_DATA) libintl.$la $(DESTDIR)$(libdir)/libintl.$la; \
else \
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \
temp=$(DESTDIR)$(libdir)/t-charset.alias; \
dest=$(DESTDIR)$(libdir)/charset.alias; \
if test -f $(DESTDIR)$(libdir)/charset.alias; then \
orig=$(DESTDIR)$(libdir)/charset.alias; \
sed -f ref-add.sed $$orig > $$temp; \
$(INSTALL_DATA) $$temp $$dest; \
rm -f $$temp; \
else \
if test @GLIBC21@ = no; then \
orig=charset.alias; \
sed -f ref-add.sed $$orig > $$temp; \
$(INSTALL_DATA) $$temp $$dest; \
rm -f $$temp; \
fi; \
fi; \
$(mkinstalldirs) $(DESTDIR)$(localedir); \
test -f $(DESTDIR)$(localedir)/locale.alias \
&& orig=$(DESTDIR)$(localedir)/locale.alias \
|| orig=$(srcdir)/locale.alias; \
temp=$(DESTDIR)$(localedir)/t-locale.alias; \
dest=$(DESTDIR)$(localedir)/locale.alias; \
sed -f ref-add.sed $$orig > $$temp; \
$(INSTALL_DATA) $$temp $$dest; \
rm -f $$temp; \
else \
: ; \
fi
install-data: all
if test "$(PACKAGE)" = "gettext"; then \
$(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
$(INSTALL_DATA) VERSION $(DESTDIR)$(gettextsrcdir)/VERSION; \
$(INSTALL_DATA) ChangeLog.inst $(DESTDIR)$(gettextsrcdir)/ChangeLog; \
dists="COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common)"; \
for file in $$dists; do \
$(INSTALL_DATA) $(srcdir)/$$file \
$(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
chmod a+x $(DESTDIR)$(gettextsrcdir)/config.charset; \
dists="$(DISTFILES.generated)"; \
for file in $$dists; do \
if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
$(INSTALL_DATA) $$dir/$$file \
$(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
dists="$(DISTFILES.obsolete)"; \
for file in $$dists; do \
rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
else \
: ; \
fi
install-strip: install
installdirs:
if test "$(PACKAGE)" = "gettext" \
&& test '@INTLOBJS@' = '$(GETTOBJS)'; then \
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir); \
else \
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
test @GLIBC21@ != no || $(mkinstalldirs) $(DESTDIR)$(libdir); \
$(mkinstalldirs) $(DESTDIR)$(localedir); \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext"; then \
$(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
else \
: ; \
fi
# Define this as empty until I found a useful application.
installcheck:
uninstall:
if test "$(PACKAGE)" = "gettext" \
&& test '@INTLOBJS@' = '$(GETTOBJS)'; then \
rm -f $(DESTDIR)$(includedir)/libintl.h; \
$(LIBTOOL) --mode=uninstall \
rm -f $(DESTDIR)$(libdir)/libintl.$la; \
else \
: ; \
fi
if test '@USE_INCLUDED_LIBINTL@' = yes; then \
if test -f $(DESTDIR)$(libdir)/charset.alias; then \
temp=$(DESTDIR)$(libdir)/t-charset.alias; \
dest=$(DESTDIR)$(libdir)/charset.alias; \
sed -f ref-del.sed $$dest > $$temp; \
if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
rm -f $$dest; \
else \
$(INSTALL_DATA) $$temp $$dest; \
fi; \
rm -f $$temp; \
fi; \
if test -f $(DESTDIR)$(localedir)/locale.alias; then \
temp=$(DESTDIR)$(localedir)/t-locale.alias; \
dest=$(DESTDIR)$(localedir)/locale.alias; \
sed -f ref-del.sed $$dest > $$temp; \
if grep '^# Packages using this file: $$' $$temp > /dev/null; then \
rm -f $$dest; \
else \
$(INSTALL_DATA) $$temp $$dest; \
fi; \
rm -f $$temp; \
fi; \
else \
: ; \
fi
if test "$(PACKAGE)" = "gettext"; then \
for file in VERSION ChangeLog COPYING.LIB-2.0 COPYING.LIB-2.1 $(DISTFILES.common) $(DISTFILES.generated); do \
rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
done; \
else \
: ; \
fi
info dvi:
$(OBJECTS): ../config.h libgnuintl.h
bindtextdom.$lo dcgettext.$lo dcigettext.$lo dcngettext.$lo dgettext.$lo dngettext.$lo finddomain.$lo gettext.$lo intl-compat.$lo loadmsgcat.$lo localealias.$lo ngettext.$lo textdomain.$lo: gettextP.h gmo.h loadinfo.h
dcigettext.$lo: hash-string.h
explodename.$lo l10nflist.$lo: loadinfo.h
dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: plural-exp.h
dcigettext.$lo: eval-plural.h
tags: TAGS
TAGS: $(HEADERS) $(SOURCES)
here=`pwd`; cd $(srcdir) && etags -o $$here/TAGS $(HEADERS) $(SOURCES)
id: ID
ID: $(HEADERS) $(SOURCES)
here=`pwd`; cd $(srcdir) && mkid -f$$here/ID $(HEADERS) $(SOURCES)
mostlyclean:
rm -f *.a *.la *.o *.lo core core.*
rm -f libintl.h charset.alias ref-add.sed ref-del.sed
rm -f -r .libs _libs
clean: mostlyclean
distclean: clean
rm -f Makefile ID TAGS
if test "$(PACKAGE)" = gettext; then \
rm -f ChangeLog.inst $(DISTFILES.normal); \
else \
: ; \
fi
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
# GNU gettext needs not contain the file `VERSION' but contains some
# other files which should not be distributed in other packages.
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
dist distdir: Makefile
if test "$(PACKAGE)" = gettext; then \
additional="$(DISTFILES.gettext)"; \
else \
additional="$(DISTFILES.normal)"; \
fi; \
$(MAKE) $(DISTFILES.common) $(DISTFILES.generated) $$additional; \
for file in ChangeLog $(DISTFILES.common) $(DISTFILES.generated) $$additional; do \
if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
cp -p $$dir/$$file $(distdir); \
done
Makefile: Makefile.in ../config.status
cd .. \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

1
elfutils/intl/VERSION Normal file
View File

@ -0,0 +1 @@
GNU gettext library from gettext-0.11.1

369
elfutils/intl/bindtextdom.c Normal file
View File

@ -0,0 +1,369 @@
/* Implementation of the bindtextdomain(3) function
Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
#include "gettextP.h"
#ifdef _LIBC
/* We have to handle multi-threaded applications. */
# include <bits/libc-lock.h>
#else
/* Provide dummy implementation if this is outside glibc. */
# define __libc_rwlock_define(CLASS, NAME)
# define __libc_rwlock_wrlock(NAME)
# define __libc_rwlock_unlock(NAME)
#endif
/* The internal variables in the standalone libintl.a must have different
names than the internal variables in GNU libc, otherwise programs
using libintl.a cannot be linked statically. */
#if !defined _LIBC
# define _nl_default_dirname _nl_default_dirname__
# define _nl_domain_bindings _nl_domain_bindings__
#endif
/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */
#ifndef offsetof
# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
#endif
/* @@ end of prolog @@ */
/* Contains the default location of the message catalogs. */
extern const char _nl_default_dirname[];
/* List with bindings of specific domains. */
extern struct binding *_nl_domain_bindings;
/* Lock variable to protect the global data in the gettext implementation. */
__libc_rwlock_define (extern, _nl_state_lock)
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define BINDTEXTDOMAIN __bindtextdomain
# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset
# ifndef strdup
# define strdup(str) __strdup (str)
# endif
#else
# define BINDTEXTDOMAIN bindtextdomain__
# define BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset__
#endif
/* Prototypes for local functions. */
static void set_binding_values PARAMS ((const char *domainname,
const char **dirnamep,
const char **codesetp));
/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
to be used for the DOMAINNAME message catalog.
If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
modified, only the current value is returned.
If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither
modified nor returned. */
static void
set_binding_values (domainname, dirnamep, codesetp)
const char *domainname;
const char **dirnamep;
const char **codesetp;
{
struct binding *binding;
int modified;
/* Some sanity checks. */
if (domainname == NULL || domainname[0] == '\0')
{
if (dirnamep)
*dirnamep = NULL;
if (codesetp)
*codesetp = NULL;
return;
}
__libc_rwlock_wrlock (_nl_state_lock);
modified = 0;
for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
{
int compare = strcmp (domainname, binding->domainname);
if (compare == 0)
/* We found it! */
break;
if (compare < 0)
{
/* It is not in the list. */
binding = NULL;
break;
}
}
if (binding != NULL)
{
if (dirnamep)
{
const char *dirname = *dirnamep;
if (dirname == NULL)
/* The current binding has be to returned. */
*dirnamep = binding->dirname;
else
{
/* The domain is already bound. If the new value and the old
one are equal we simply do nothing. Otherwise replace the
old binding. */
char *result = binding->dirname;
if (strcmp (dirname, result) != 0)
{
if (strcmp (dirname, _nl_default_dirname) == 0)
result = (char *) _nl_default_dirname;
else
{
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (dirname);
#else
size_t len = strlen (dirname) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result != NULL, 1))
memcpy (result, dirname, len);
#endif
}
if (__builtin_expect (result != NULL, 1))
{
if (binding->dirname != _nl_default_dirname)
free (binding->dirname);
binding->dirname = result;
modified = 1;
}
}
*dirnamep = result;
}
}
if (codesetp)
{
const char *codeset = *codesetp;
if (codeset == NULL)
/* The current binding has be to returned. */
*codesetp = binding->codeset;
else
{
/* The domain is already bound. If the new value and the old
one are equal we simply do nothing. Otherwise replace the
old binding. */
char *result = binding->codeset;
if (result == NULL || strcmp (codeset, result) != 0)
{
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (codeset);
#else
size_t len = strlen (codeset) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result != NULL, 1))
memcpy (result, codeset, len);
#endif
if (__builtin_expect (result != NULL, 1))
{
if (binding->codeset != NULL)
free (binding->codeset);
binding->codeset = result;
binding->codeset_cntr++;
modified = 1;
}
}
*codesetp = result;
}
}
}
else if ((dirnamep == NULL || *dirnamep == NULL)
&& (codesetp == NULL || *codesetp == NULL))
{
/* Simply return the default values. */
if (dirnamep)
*dirnamep = _nl_default_dirname;
if (codesetp)
*codesetp = NULL;
}
else
{
/* We have to create a new binding. */
size_t len = strlen (domainname) + 1;
struct binding *new_binding =
(struct binding *) malloc (offsetof (struct binding, domainname) + len);
if (__builtin_expect (new_binding == NULL, 0))
goto failed;
memcpy (new_binding->domainname, domainname, len);
if (dirnamep)
{
const char *dirname = *dirnamep;
if (dirname == NULL)
/* The default value. */
dirname = _nl_default_dirname;
else
{
if (strcmp (dirname, _nl_default_dirname) == 0)
dirname = _nl_default_dirname;
else
{
char *result;
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (dirname);
if (__builtin_expect (result == NULL, 0))
goto failed_dirname;
#else
size_t len = strlen (dirname) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result == NULL, 0))
goto failed_dirname;
memcpy (result, dirname, len);
#endif
dirname = result;
}
}
*dirnamep = dirname;
new_binding->dirname = (char *) dirname;
}
else
/* The default value. */
new_binding->dirname = (char *) _nl_default_dirname;
new_binding->codeset_cntr = 0;
if (codesetp)
{
const char *codeset = *codesetp;
if (codeset != NULL)
{
char *result;
#if defined _LIBC || defined HAVE_STRDUP
result = strdup (codeset);
if (__builtin_expect (result == NULL, 0))
goto failed_codeset;
#else
size_t len = strlen (codeset) + 1;
result = (char *) malloc (len);
if (__builtin_expect (result == NULL, 0))
goto failed_codeset;
memcpy (result, codeset, len);
#endif
codeset = result;
new_binding->codeset_cntr++;
}
*codesetp = codeset;
new_binding->codeset = (char *) codeset;
}
else
new_binding->codeset = NULL;
/* Now enqueue it. */
if (_nl_domain_bindings == NULL
|| strcmp (domainname, _nl_domain_bindings->domainname) < 0)
{
new_binding->next = _nl_domain_bindings;
_nl_domain_bindings = new_binding;
}
else
{
binding = _nl_domain_bindings;
while (binding->next != NULL
&& strcmp (domainname, binding->next->domainname) > 0)
binding = binding->next;
new_binding->next = binding->next;
binding->next = new_binding;
}
modified = 1;
/* Here we deal with memory allocation failures. */
if (0)
{
failed_codeset:
if (new_binding->dirname != _nl_default_dirname)
free (new_binding->dirname);
failed_dirname:
free (new_binding);
failed:
if (dirnamep)
*dirnamep = NULL;
if (codesetp)
*codesetp = NULL;
}
}
/* If we modified any binding, we flush the caches. */
if (modified)
++_nl_msg_cat_cntr;
__libc_rwlock_unlock (_nl_state_lock);
}
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
char *
BINDTEXTDOMAIN (domainname, dirname)
const char *domainname;
const char *dirname;
{
set_binding_values (domainname, &dirname, NULL);
return (char *) dirname;
}
/* Specify the character encoding in which the messages from the
DOMAINNAME message catalog will be returned. */
char *
BIND_TEXTDOMAIN_CODESET (domainname, codeset)
const char *domainname;
const char *codeset;
{
set_binding_values (domainname, NULL, &codeset);
return (char *) codeset;
}
#ifdef _LIBC
/* Aliases for function names in GNU C Library. */
weak_alias (__bindtextdomain, bindtextdomain);
weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset);
#endif

454
elfutils/intl/config.charset Executable file
View File

@ -0,0 +1,454 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
# Copyright (C) 2000-2002 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# The table consists of lines of the form
# ALIAS CANONICAL
#
# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
# ALIAS is compared in a case sensitive way.
#
# CANONICAL is the GNU canonical name for this character encoding.
# It must be an encoding supported by libiconv. Support by GNU libc is
# also desirable. CANONICAL is case insensitive. Usually an upper case
# MIME charset name is preferred.
# The current list of GNU canonical charset names is as follows.
#
# name used by which systems a MIME name?
# ASCII, ANSI_X3.4-1968 glibc solaris freebsd
# ISO-8859-1 glibc aix hpux irix osf solaris freebsd yes
# ISO-8859-2 glibc aix hpux irix osf solaris freebsd yes
# ISO-8859-3 glibc yes
# ISO-8859-4 osf solaris freebsd yes
# ISO-8859-5 glibc aix hpux irix osf solaris freebsd yes
# ISO-8859-6 glibc aix hpux solaris yes
# ISO-8859-7 glibc aix hpux irix osf solaris yes
# ISO-8859-8 glibc aix hpux osf solaris yes
# ISO-8859-9 glibc aix hpux irix osf solaris yes
# ISO-8859-13 glibc
# ISO-8859-15 glibc aix osf solaris freebsd
# KOI8-R glibc solaris freebsd yes
# KOI8-U glibc freebsd yes
# CP437 dos
# CP775 dos
# CP850 aix osf dos
# CP852 dos
# CP855 dos
# CP856 aix
# CP857 dos
# CP861 dos
# CP862 dos
# CP864 dos
# CP865 dos
# CP866 freebsd dos
# CP869 dos
# CP874 win32 dos
# CP922 aix
# CP932 aix win32 dos
# CP943 aix
# CP949 osf win32 dos
# CP950 win32 dos
# CP1046 aix
# CP1124 aix
# CP1129 aix
# CP1250 win32
# CP1251 glibc win32
# CP1252 aix win32
# CP1253 win32
# CP1254 win32
# CP1255 win32
# CP1256 win32
# CP1257 win32
# GB2312 glibc aix hpux irix solaris freebsd yes
# EUC-JP glibc aix hpux irix osf solaris freebsd yes
# EUC-KR glibc aix hpux irix osf solaris freebsd yes
# EUC-TW glibc aix hpux irix osf solaris
# BIG5 glibc aix hpux osf solaris freebsd yes
# BIG5-HKSCS glibc
# GBK aix osf win32 dos
# GB18030 glibc
# SHIFT_JIS hpux osf solaris freebsd yes
# JOHAB glibc win32
# TIS-620 glibc aix hpux osf solaris
# VISCII glibc yes
# HP-ROMAN8 hpux
# HP-ARABIC8 hpux
# HP-GREEK8 hpux
# HP-HEBREW8 hpux
# HP-TURKISH8 hpux
# HP-KANA8 hpux
# DEC-KANJI osf
# DEC-HANYU osf
# UTF-8 glibc aix hpux osf solaris yes
#
# Note: Names which are not marked as being a MIME name should not be used in
# Internet protocols for information interchange (mail, news, etc.).
#
# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
# must understand both names and treat them as equivalent.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
host="$1"
os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
echo "# This file contains a table of character encoding aliases,"
echo "# suitable for operating system '${os}'."
echo "# It was automatically generated from config.charset."
# List of references, updated during installation:
echo "# Packages using this file: "
case "$os" in
linux* | *-gnu*)
# With glibc-2.1 or newer, we don't need any canonicalization,
# because glibc has iconv and both glibc and libiconv support all
# GNU canonical names directly. Therefore, the Makefile does not
# need to install the alias file at all.
# The following applies only to glibc-2.0.x and older libcs.
echo "ISO_646.IRV:1983 ASCII"
;;
aix*)
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-6 ISO-8859-6"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-8 ISO-8859-8"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-15 ISO-8859-15"
echo "IBM-850 CP850"
echo "IBM-856 CP856"
echo "IBM-921 ISO-8859-13"
echo "IBM-922 CP922"
echo "IBM-932 CP932"
echo "IBM-943 CP943"
echo "IBM-1046 CP1046"
echo "IBM-1124 CP1124"
echo "IBM-1129 CP1129"
echo "IBM-1252 CP1252"
echo "IBM-eucCN GB2312"
echo "IBM-eucJP EUC-JP"
echo "IBM-eucKR EUC-KR"
echo "IBM-eucTW EUC-TW"
echo "big5 BIG5"
echo "GBK GBK"
echo "TIS-620 TIS-620"
echo "UTF-8 UTF-8"
;;
hpux*)
echo "iso88591 ISO-8859-1"
echo "iso88592 ISO-8859-2"
echo "iso88595 ISO-8859-5"
echo "iso88596 ISO-8859-6"
echo "iso88597 ISO-8859-7"
echo "iso88598 ISO-8859-8"
echo "iso88599 ISO-8859-9"
echo "iso885915 ISO-8859-15"
echo "roman8 HP-ROMAN8"
echo "arabic8 HP-ARABIC8"
echo "greek8 HP-GREEK8"
echo "hebrew8 HP-HEBREW8"
echo "turkish8 HP-TURKISH8"
echo "kana8 HP-KANA8"
echo "tis620 TIS-620"
echo "big5 BIG5"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "hp15CN GB2312"
#echo "ccdc ?" # what is this?
echo "SJIS SHIFT_JIS"
echo "utf8 UTF-8"
;;
irix*)
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-9 ISO-8859-9"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
;;
osf*)
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-8 ISO-8859-8"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-15 ISO-8859-15"
echo "cp850 CP850"
echo "big5 BIG5"
echo "dechanyu DEC-HANYU"
echo "dechanzi GB2312"
echo "deckanji DEC-KANJI"
echo "deckorean EUC-KR"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "GBK GBK"
echo "KSC5601 CP949"
echo "sdeckanji EUC-JP"
echo "SJIS SHIFT_JIS"
echo "TACTIS TIS-620"
echo "UTF-8 UTF-8"
;;
solaris*)
echo "646 ASCII"
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-6 ISO-8859-6"
echo "ISO8859-7 ISO-8859-7"
echo "ISO8859-8 ISO-8859-8"
echo "ISO8859-9 ISO-8859-9"
echo "ISO8859-15 ISO-8859-15"
echo "koi8-r KOI8-R"
echo "BIG5 BIG5"
echo "gb2312 GB2312"
echo "cns11643 EUC-TW"
echo "5601 EUC-KR"
echo "eucJP EUC-JP"
echo "PCK SHIFT_JIS"
echo "TIS620.2533 TIS-620"
#echo "sun_eu_greek ?" # what is this?
echo "UTF-8 UTF-8"
;;
freebsd* | os2*)
# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
# Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
# reuse FreeBSD's locale data for OS/2.
echo "C ASCII"
echo "US-ASCII ASCII"
for l in la_LN lt_LN; do
echo "$l.ASCII ASCII"
done
for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
echo "$l.ISO_8859-1 ISO-8859-1"
echo "$l.DIS_8859-15 ISO-8859-15"
done
for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
echo "$l.ISO_8859-2 ISO-8859-2"
done
for l in la_LN lt_LT; do
echo "$l.ISO_8859-4 ISO-8859-4"
done
for l in ru_RU ru_SU; do
echo "$l.KOI8-R KOI8-R"
echo "$l.ISO_8859-5 ISO-8859-5"
echo "$l.CP866 CP866"
done
echo "uk_UA.KOI8-U KOI8-U"
echo "zh_TW.BIG5 BIG5"
echo "zh_TW.Big5 BIG5"
echo "zh_CN.EUC GB2312"
echo "ja_JP.EUC EUC-JP"
echo "ja_JP.SJIS SHIFT_JIS"
echo "ja_JP.Shift_JIS SHIFT_JIS"
echo "ko_KR.EUC EUC-KR"
;;
netbsd*)
echo "646 ASCII"
echo "ISO8859-1 ISO-8859-1"
echo "ISO8859-2 ISO-8859-2"
echo "ISO8859-4 ISO-8859-4"
echo "ISO8859-5 ISO-8859-5"
echo "ISO8859-15 ISO-8859-15"
echo "eucCN GB2312"
echo "eucJP EUC-JP"
echo "eucKR EUC-KR"
echo "eucTW EUC-TW"
echo "BIG5 BIG5"
echo "SJIS SHIFT_JIS"
;;
beos*)
# BeOS has a single locale, and it has UTF-8 encoding.
echo "* UTF-8"
;;
msdosdjgpp*)
# DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
# localcharset.c falls back to using the full locale name
# from the environment variables.
echo "#"
echo "# The encodings given here may not all be correct."
echo "# If you find that the encoding given for your language and"
echo "# country is not the one your DOS machine actually uses, just"
echo "# correct it in this file, and send a mail to"
echo "# Juan Manuel Guerrero <st001906@hrz1.hrz.tu-darmstadt.de>"
echo "# and Bruno Haible <haible@clisp.cons.org>."
echo "#"
echo "C ASCII"
# ISO-8859-1 languages
echo "ca CP850"
echo "ca_ES CP850"
echo "da CP865" # not CP850 ??
echo "da_DK CP865" # not CP850 ??
echo "de CP850"
echo "de_AT CP850"
echo "de_CH CP850"
echo "de_DE CP850"
echo "en CP850"
echo "en_AU CP850" # not CP437 ??
echo "en_CA CP850"
echo "en_GB CP850"
echo "en_NZ CP437"
echo "en_US CP437"
echo "en_ZA CP850" # not CP437 ??
echo "es CP850"
echo "es_AR CP850"
echo "es_BO CP850"
echo "es_CL CP850"
echo "es_CO CP850"
echo "es_CR CP850"
echo "es_CU CP850"
echo "es_DO CP850"
echo "es_EC CP850"
echo "es_ES CP850"
echo "es_GT CP850"
echo "es_HN CP850"
echo "es_MX CP850"
echo "es_NI CP850"
echo "es_PA CP850"
echo "es_PY CP850"
echo "es_PE CP850"
echo "es_SV CP850"
echo "es_UY CP850"
echo "es_VE CP850"
echo "et CP850"
echo "et_EE CP850"
echo "eu CP850"
echo "eu_ES CP850"
echo "fi CP850"
echo "fi_FI CP850"
echo "fr CP850"
echo "fr_BE CP850"
echo "fr_CA CP850"
echo "fr_CH CP850"
echo "fr_FR CP850"
echo "ga CP850"
echo "ga_IE CP850"
echo "gd CP850"
echo "gd_GB CP850"
echo "gl CP850"
echo "gl_ES CP850"
echo "id CP850" # not CP437 ??
echo "id_ID CP850" # not CP437 ??
echo "is CP861" # not CP850 ??
echo "is_IS CP861" # not CP850 ??
echo "it CP850"
echo "it_CH CP850"
echo "it_IT CP850"
echo "lt CP775"
echo "lt_LT CP775"
echo "lv CP775"
echo "lv_LV CP775"
echo "nb CP865" # not CP850 ??
echo "nb_NO CP865" # not CP850 ??
echo "nl CP850"
echo "nl_BE CP850"
echo "nl_NL CP850"
echo "nn CP865" # not CP850 ??
echo "nn_NO CP865" # not CP850 ??
echo "no CP865" # not CP850 ??
echo "no_NO CP865" # not CP850 ??
echo "pt CP850"
echo "pt_BR CP850"
echo "pt_PT CP850"
echo "sv CP850"
echo "sv_SE CP850"
# ISO-8859-2 languages
echo "cs CP852"
echo "cs_CZ CP852"
echo "hr CP852"
echo "hr_HR CP852"
echo "hu CP852"
echo "hu_HU CP852"
echo "pl CP852"
echo "pl_PL CP852"
echo "ro CP852"
echo "ro_RO CP852"
echo "sk CP852"
echo "sk_SK CP852"
echo "sl CP852"
echo "sl_SI CP852"
echo "sq CP852"
echo "sq_AL CP852"
echo "sr CP852" # CP852 or CP866 or CP855 ??
echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
# ISO-8859-3 languages
echo "mt CP850"
echo "mt_MT CP850"
# ISO-8859-5 languages
echo "be CP866"
echo "be_BE CP866"
echo "bg CP866" # not CP855 ??
echo "bg_BG CP866" # not CP855 ??
echo "mk CP866" # not CP855 ??
echo "mk_MK CP866" # not CP855 ??
echo "ru CP866"
echo "ru_RU CP866"
# ISO-8859-6 languages
echo "ar CP864"
echo "ar_AE CP864"
echo "ar_DZ CP864"
echo "ar_EG CP864"
echo "ar_IQ CP864"
echo "ar_IR CP864"
echo "ar_JO CP864"
echo "ar_KW CP864"
echo "ar_MA CP864"
echo "ar_OM CP864"
echo "ar_QA CP864"
echo "ar_SA CP864"
echo "ar_SY CP864"
# ISO-8859-7 languages
echo "el CP869"
echo "el_GR CP869"
# ISO-8859-8 languages
echo "he CP862"
echo "he_IL CP862"
# ISO-8859-9 languages
echo "tr CP857"
echo "tr_TR CP857"
# Japanese
echo "ja CP932"
echo "ja_JP CP932"
# Chinese
echo "zh_CN GBK"
echo "zh_TW CP950" # not CP938 ??
# Korean
echo "kr CP949" # not CP934 ??
echo "kr_KR CP949" # not CP934 ??
# Thai
echo "th CP874"
echo "th_TH CP874"
# Other
echo "eo CP850"
echo "eo_EO CP850"
;;
esac

58
elfutils/intl/dcgettext.c Normal file
View File

@ -0,0 +1,58 @@
/* Implementation of the dcgettext(3) function.
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DCGETTEXT __dcgettext
# define DCIGETTEXT __dcigettext
#else
# define DCGETTEXT dcgettext__
# define DCIGETTEXT dcigettext__
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
char *
DCGETTEXT (domainname, msgid, category)
const char *domainname;
const char *msgid;
int category;
{
return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dcgettext, dcgettext);
#endif

1167
elfutils/intl/dcigettext.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
/* Implementation of the dcngettext(3) function.
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DCNGETTEXT __dcngettext
# define DCIGETTEXT __dcigettext
#else
# define DCNGETTEXT dcngettext__
# define DCIGETTEXT dcigettext__
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
char *
DCNGETTEXT (domainname, msgid1, msgid2, n, category)
const char *domainname;
const char *msgid1;
const char *msgid2;
unsigned long int n;
int category;
{
return DCIGETTEXT (domainname, msgid1, msgid2, 1, n, category);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dcngettext, dcngettext);
#endif

59
elfutils/intl/dgettext.c Normal file
View File

@ -0,0 +1,59 @@
/* Implementation of the dgettext(3) function.
Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <locale.h>
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DGETTEXT __dgettext
# define DCGETTEXT __dcgettext
#else
# define DGETTEXT dgettext__
# define DCGETTEXT dcgettext__
#endif
/* Look up MSGID in the DOMAINNAME message catalog of the current
LC_MESSAGES locale. */
char *
DGETTEXT (domainname, msgid)
const char *domainname;
const char *msgid;
{
return DCGETTEXT (domainname, msgid, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dgettext, dgettext);
#endif

61
elfutils/intl/dngettext.c Normal file
View File

@ -0,0 +1,61 @@
/* Implementation of the dngettext(3) function.
Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <locale.h>
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define DNGETTEXT __dngettext
# define DCNGETTEXT __dcngettext
#else
# define DNGETTEXT dngettext__
# define DCNGETTEXT dcngettext__
#endif
/* Look up MSGID in the DOMAINNAME message catalog of the current
LC_MESSAGES locale and skip message according to the plural form. */
char *
DNGETTEXT (domainname, msgid1, msgid2, n)
const char *domainname;
const char *msgid1;
const char *msgid2;
unsigned long int n;
{
return DCNGETTEXT (domainname, msgid1, msgid2, n, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__dngettext, dngettext);
#endif

106
elfutils/intl/eval-plural.h Normal file
View File

@ -0,0 +1,106 @@
/* Plural expression evaluation.
Copyright (C) 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef STATIC
#define STATIC static
#endif
/* Evaluate the plural expression and return an index value. */
STATIC unsigned long int plural_eval PARAMS ((struct expression *pexp,
unsigned long int n))
internal_function;
STATIC
unsigned long int
internal_function
plural_eval (pexp, n)
struct expression *pexp;
unsigned long int n;
{
switch (pexp->nargs)
{
case 0:
switch (pexp->operation)
{
case var:
return n;
case num:
return pexp->val.num;
default:
break;
}
/* NOTREACHED */
break;
case 1:
{
/* pexp->operation must be lnot. */
unsigned long int arg = plural_eval (pexp->val.args[0], n);
return ! arg;
}
case 2:
{
unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
if (pexp->operation == lor)
return leftarg || plural_eval (pexp->val.args[1], n);
else if (pexp->operation == land)
return leftarg && plural_eval (pexp->val.args[1], n);
else
{
unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
switch (pexp->operation)
{
case mult:
return leftarg * rightarg;
case divide:
return leftarg / rightarg;
case module:
return leftarg % rightarg;
case plus:
return leftarg + rightarg;
case minus:
return leftarg - rightarg;
case less_than:
return leftarg < rightarg;
case greater_than:
return leftarg > rightarg;
case less_or_equal:
return leftarg <= rightarg;
case greater_or_equal:
return leftarg >= rightarg;
case equal:
return leftarg == rightarg;
case not_equal:
return leftarg != rightarg;
default:
break;
}
}
/* NOTREACHED */
break;
}
case 3:
{
/* pexp->operation must be qmop. */
unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
}
}
/* NOTREACHED */
return 0;
}

192
elfutils/intl/explodename.c Normal file
View File

@ -0,0 +1,192 @@
/* Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "loadinfo.h"
/* On some strange systems still no definition of NULL is found. Sigh! */
#ifndef NULL
# if defined __STDC__ && __STDC__
# define NULL ((void *) 0)
# else
# define NULL 0
# endif
#endif
/* @@ end of prolog @@ */
char *
_nl_find_language (name)
const char *name;
{
while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
&& name[0] != '+' && name[0] != ',')
++name;
return (char *) name;
}
int
_nl_explode_name (name, language, modifier, territory, codeset,
normalized_codeset, special, sponsor, revision)
char *name;
const char **language;
const char **modifier;
const char **territory;
const char **codeset;
const char **normalized_codeset;
const char **special;
const char **sponsor;
const char **revision;
{
enum { undecided, xpg, cen } syntax;
char *cp;
int mask;
*modifier = NULL;
*territory = NULL;
*codeset = NULL;
*normalized_codeset = NULL;
*special = NULL;
*sponsor = NULL;
*revision = NULL;
/* Now we determine the single parts of the locale name. First
look for the language. Termination symbols are `_' and `@' if
we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
mask = 0;
syntax = undecided;
*language = cp = name;
cp = _nl_find_language (*language);
if (*language == cp)
/* This does not make sense: language has to be specified. Use
this entry as it is without exploding. Perhaps it is an alias. */
cp = strchr (*language, '\0');
else if (cp[0] == '_')
{
/* Next is the territory. */
cp[0] = '\0';
*territory = ++cp;
while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
&& cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
++cp;
mask |= TERRITORY;
if (cp[0] == '.')
{
/* Next is the codeset. */
syntax = xpg;
cp[0] = '\0';
*codeset = ++cp;
while (cp[0] != '\0' && cp[0] != '@')
++cp;
mask |= XPG_CODESET;
if (*codeset != cp && (*codeset)[0] != '\0')
{
*normalized_codeset = _nl_normalize_codeset (*codeset,
cp - *codeset);
if (strcmp (*codeset, *normalized_codeset) == 0)
free ((char *) *normalized_codeset);
else
mask |= XPG_NORM_CODESET;
}
}
}
if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
{
/* Next is the modifier. */
syntax = cp[0] == '@' ? xpg : cen;
cp[0] = '\0';
*modifier = ++cp;
while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
&& cp[0] != ',' && cp[0] != '_')
++cp;
mask |= XPG_MODIFIER | CEN_AUDIENCE;
}
if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
{
syntax = cen;
if (cp[0] == '+')
{
/* Next is special application (CEN syntax). */
cp[0] = '\0';
*special = ++cp;
while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
++cp;
mask |= CEN_SPECIAL;
}
if (cp[0] == ',')
{
/* Next is sponsor (CEN syntax). */
cp[0] = '\0';
*sponsor = ++cp;
while (cp[0] != '\0' && cp[0] != '_')
++cp;
mask |= CEN_SPONSOR;
}
if (cp[0] == '_')
{
/* Next is revision (CEN syntax). */
cp[0] = '\0';
*revision = ++cp;
mask |= CEN_REVISION;
}
}
/* For CEN syntax values it might be important to have the
separator character in the file name, not for XPG syntax. */
if (syntax == xpg)
{
if (*territory != NULL && (*territory)[0] == '\0')
mask &= ~TERRITORY;
if (*codeset != NULL && (*codeset)[0] == '\0')
mask &= ~XPG_CODESET;
if (*modifier != NULL && (*modifier)[0] == '\0')
mask &= ~XPG_MODIFIER;
}
return mask;
}

198
elfutils/intl/finddomain.c Normal file
View File

@ -0,0 +1,198 @@
/* Handle list of needed message catalogs
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@gnu.org>, 1995.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h>
#endif
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* List of already loaded domains. */
static struct loaded_l10nfile *_nl_loaded_domains;
/* Return a data structure describing the message catalog described by
the DOMAINNAME and CATEGORY parameters with respect to the currently
established bindings. */
struct loaded_l10nfile *
internal_function
_nl_find_domain (dirname, locale, domainname, domainbinding)
const char *dirname;
char *locale;
const char *domainname;
struct binding *domainbinding;
{
struct loaded_l10nfile *retval;
const char *language;
const char *modifier;
const char *territory;
const char *codeset;
const char *normalized_codeset;
const char *special;
const char *sponsor;
const char *revision;
const char *alias_value;
int mask;
/* LOCALE can consist of up to four recognized parts for the XPG syntax:
language[_territory[.codeset]][@modifier]
and six parts for the CEN syntax:
language[_territory][+audience][+special][,[sponsor][_revision]]
Beside the first part all of them are allowed to be missing. If
the full specified locale is not found, the less specific one are
looked for. The various parts will be stripped off according to
the following order:
(1) revision
(2) sponsor
(3) special
(4) codeset
(5) normalized codeset
(6) territory
(7) audience/modifier
*/
/* If we have already tested for this locale entry there has to
be one data set in the list of loaded domains. */
retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
strlen (dirname) + 1, 0, locale, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, domainname, 0);
if (retval != NULL)
{
/* We know something about this locale. */
int cnt;
if (retval->decided == 0)
_nl_load_domain (retval, domainbinding);
if (retval->data != NULL)
return retval;
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
{
if (retval->successor[cnt]->decided == 0)
_nl_load_domain (retval->successor[cnt], domainbinding);
if (retval->successor[cnt]->data != NULL)
break;
}
return cnt >= 0 ? retval : NULL;
/* NOTREACHED */
}
/* See whether the locale value is an alias. If yes its value
*overwrites* the alias name. No test for the original value is
done. */
alias_value = _nl_expand_alias (locale);
if (alias_value != NULL)
{
#if defined _LIBC || defined HAVE_STRDUP
locale = strdup (alias_value);
if (locale == NULL)
return NULL;
#else
size_t len = strlen (alias_value) + 1;
locale = (char *) malloc (len);
if (locale == NULL)
return NULL;
memcpy (locale, alias_value, len);
#endif
}
/* Now we determine the single parts of the locale name. First
look for the language. Termination symbols are `_' and `@' if
we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
mask = _nl_explode_name (locale, &language, &modifier, &territory,
&codeset, &normalized_codeset, &special,
&sponsor, &revision);
/* Create all possible locale entries which might be interested in
generalization. */
retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
strlen (dirname) + 1, mask, language, territory,
codeset, normalized_codeset, modifier, special,
sponsor, revision, domainname, 1);
if (retval == NULL)
/* This means we are out of core. */
return NULL;
if (retval->decided == 0)
_nl_load_domain (retval, domainbinding);
if (retval->data == NULL)
{
int cnt;
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
{
if (retval->successor[cnt]->decided == 0)
_nl_load_domain (retval->successor[cnt], domainbinding);
if (retval->successor[cnt]->data != NULL)
break;
}
}
/* The room for an alias was dynamically allocated. Free it now. */
if (alias_value != NULL)
free (locale);
/* The space for normalized_codeset is dynamically allocated. Free it. */
if (mask & XPG_NORM_CODESET)
free ((void *) normalized_codeset);
return retval;
}
#ifdef _LIBC
static void __attribute__ ((unused))
free_mem (void)
{
struct loaded_l10nfile *runp = _nl_loaded_domains;
while (runp != NULL)
{
struct loaded_l10nfile *here = runp;
if (runp->data != NULL)
_nl_unload_domain ((struct loaded_domain *) runp->data);
runp = runp->next;
free ((char *) here->filename);
free (here);
}
}
text_set_element (__libc_subfreeres, free_mem);
#endif

64
elfutils/intl/gettext.c Normal file
View File

@ -0,0 +1,64 @@
/* Implementation of gettext(3) function.
Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef _LIBC
# define __need_NULL
# include <stddef.h>
#else
# include <stdlib.h> /* Just for NULL. */
#endif
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define GETTEXT __gettext
# define DCGETTEXT __dcgettext
#else
# define GETTEXT gettext__
# define DCGETTEXT dcgettext__
#endif
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
char *
GETTEXT (msgid)
const char *msgid;
{
return DCGETTEXT (NULL, msgid, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__gettext, gettext);
#endif

201
elfutils/intl/gettextP.h Normal file
View File

@ -0,0 +1,201 @@
/* Header describing internals of libintl library.
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _GETTEXTP_H
#define _GETTEXTP_H
#include <stddef.h> /* Get size_t. */
#ifdef _LIBC
# include "../iconv/gconv_int.h"
#else
# if HAVE_ICONV
# include <iconv.h>
# endif
#endif
#include "loadinfo.h"
#include "gmo.h" /* Get nls_uint32. */
/* @@ end of prolog @@ */
#ifndef PARAMS
# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif
#endif
#ifndef internal_function
# define internal_function
#endif
/* Tell the compiler when a conditional or integer expression is
almost always true or almost always false. */
#ifndef HAVE_BUILTIN_EXPECT
# define __builtin_expect(expr, val) (expr)
#endif
#ifndef W
# define W(flag, data) ((flag) ? SWAP (data) : (data))
#endif
#ifdef _LIBC
# include <byteswap.h>
# define SWAP(i) bswap_32 (i)
#else
static inline nls_uint32
SWAP (i)
nls_uint32 i;
{
return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
}
#endif
/* The representation of an opened message catalog. */
struct loaded_domain
{
const char *data;
int use_mmap;
size_t mmap_size;
int must_swap;
nls_uint32 nstrings;
struct string_desc *orig_tab;
struct string_desc *trans_tab;
nls_uint32 hash_size;
nls_uint32 *hash_tab;
int codeset_cntr;
#ifdef _LIBC
__gconv_t conv;
#else
# if HAVE_ICONV
iconv_t conv;
# endif
#endif
char **conv_tab;
struct expression *plural;
unsigned long int nplurals;
};
/* We want to allocate a string at the end of the struct. But ISO C
doesn't allow zero sized arrays. */
#ifdef __GNUC__
# define ZERO 0
#else
# define ZERO 1
#endif
/* A set of settings bound to a message domain. Used to store settings
from bindtextdomain() and bind_textdomain_codeset(). */
struct binding
{
struct binding *next;
char *dirname;
int codeset_cntr; /* Incremented each time codeset changes. */
char *codeset;
char domainname[ZERO];
};
/* A counter which is incremented each time some previous translations
become invalid.
This variable is part of the external ABI of the GNU libintl. */
extern int _nl_msg_cat_cntr;
#ifndef _LIBC
const char *_nl_locale_name PARAMS ((int category, const char *categoryname));
#endif
struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname,
char *__locale,
const char *__domainname,
struct binding *__domainbinding))
internal_function;
void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain,
struct binding *__domainbinding))
internal_function;
void _nl_unload_domain PARAMS ((struct loaded_domain *__domain))
internal_function;
const char *_nl_init_domain_conv PARAMS ((struct loaded_l10nfile *__domain_file,
struct loaded_domain *__domain,
struct binding *__domainbinding))
internal_function;
void _nl_free_domain_conv PARAMS ((struct loaded_domain *__domain))
internal_function;
char *_nl_find_msg PARAMS ((struct loaded_l10nfile *domain_file,
struct binding *domainbinding,
const char *msgid, size_t *lengthp))
internal_function;
#ifdef _LIBC
extern char *__gettext PARAMS ((const char *__msgid));
extern char *__dgettext PARAMS ((const char *__domainname,
const char *__msgid));
extern char *__dcgettext PARAMS ((const char *__domainname,
const char *__msgid, int __category));
extern char *__ngettext PARAMS ((const char *__msgid1, const char *__msgid2,
unsigned long int __n));
extern char *__dngettext PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int n));
extern char *__dcngettext PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category));
extern char *__dcigettext PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid2,
int __plural, unsigned long int __n,
int __category));
extern char *__textdomain PARAMS ((const char *__domainname));
extern char *__bindtextdomain PARAMS ((const char *__domainname,
const char *__dirname));
extern char *__bind_textdomain_codeset PARAMS ((const char *__domainname,
const char *__codeset));
#else
extern char *gettext__ PARAMS ((const char *__msgid));
extern char *dgettext__ PARAMS ((const char *__domainname,
const char *__msgid));
extern char *dcgettext__ PARAMS ((const char *__domainname,
const char *__msgid, int __category));
extern char *ngettext__ PARAMS ((const char *__msgid1, const char *__msgid2,
unsigned long int __n));
extern char *dngettext__ PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n));
extern char *dcngettext__ PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid2,
unsigned long int __n, int __category));
extern char *dcigettext__ PARAMS ((const char *__domainname,
const char *__msgid1, const char *__msgid2,
int __plural, unsigned long int __n,
int __category));
extern char *textdomain__ PARAMS ((const char *__domainname));
extern char *bindtextdomain__ PARAMS ((const char *__domainname,
const char *__dirname));
extern char *bind_textdomain_codeset__ PARAMS ((const char *__domainname,
const char *__codeset));
#endif
/* @@ begin of epilog @@ */
#endif /* gettextP.h */

100
elfutils/intl/gmo.h Normal file
View File

@ -0,0 +1,100 @@
/* Description of GNU message catalog format: general file layout.
Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _GETTEXT_H
#define _GETTEXT_H 1
#include <limits.h>
/* @@ end of prolog @@ */
/* The magic number of the GNU message catalog format. */
#define _MAGIC 0x950412de
#define _MAGIC_SWAPPED 0xde120495
/* Revision number of the currently used .mo (binary) file format. */
#define MO_REVISION_NUMBER 0
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
when cross-compiling. */
#if __STDC__
# define UINT_MAX_32_BITS 4294967295U
#else
# define UINT_MAX_32_BITS 0xFFFFFFFF
#endif
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
This should be valid for all systems GNU cares about because
that doesn't include 16-bit systems, and only modern systems
(that certainly have <limits.h>) have 64+-bit integral types. */
#ifndef UINT_MAX
# define UINT_MAX UINT_MAX_32_BITS
#endif
#if UINT_MAX == UINT_MAX_32_BITS
typedef unsigned nls_uint32;
#else
# if USHRT_MAX == UINT_MAX_32_BITS
typedef unsigned short nls_uint32;
# else
# if ULONG_MAX == UINT_MAX_32_BITS
typedef unsigned long nls_uint32;
# else
/* The following line is intended to throw an error. Using #error is
not portable enough. */
"Cannot determine unsigned 32-bit data type."
# endif
# endif
#endif
/* Header for binary .mo file format. */
struct mo_file_header
{
/* The magic number. */
nls_uint32 magic;
/* The revision number of the file format. */
nls_uint32 revision;
/* The number of strings pairs. */
nls_uint32 nstrings;
/* Offset of table with start offsets of original strings. */
nls_uint32 orig_tab_offset;
/* Offset of table with start offsets of translation strings. */
nls_uint32 trans_tab_offset;
/* Size of hashing table. */
nls_uint32 hash_tab_size;
/* Offset of first hashing entry. */
nls_uint32 hash_tab_offset;
};
struct string_desc
{
/* Length of addressed string. */
nls_uint32 length;
/* Offset of string in file. */
nls_uint32 offset;
};
/* @@ begin of epilog @@ */
#endif /* gettext.h */

View File

@ -0,0 +1,59 @@
/* Description of GNU message catalog format: string hashing function.
Copyright (C) 1995, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* @@ end of prolog @@ */
#ifndef PARAMS
# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
/* We assume to have `unsigned long int' value with at least 32 bits. */
#define HASHWORDBITS 32
/* Defines the so called `hashpjw' function by P.J. Weinberger
[see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
1986, 1987 Bell Telephone Laboratories, Inc.] */
static unsigned long int hash_string PARAMS ((const char *__str_param));
static inline unsigned long int
hash_string (str_param)
const char *str_param;
{
unsigned long int hval, g;
const char *str = str_param;
/* Compute the hash value for the given string. */
hval = 0;
while (*str != '\0')
{
hval <<= 4;
hval += (unsigned long int) *str++;
g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
if (g != 0)
{
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
}
return hval;
}

166
elfutils/intl/intl-compat.c Normal file
View File

@ -0,0 +1,166 @@
/* intl-compat.c - Stub functions to call gettext functions from GNU gettext
Library.
Copyright (C) 1995, 2000, 2001 Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "libgnuintl.h"
#include "gettextP.h"
/* @@ end of prolog @@ */
/* This file redirects the gettext functions (without prefix or suffix) to
those defined in the included GNU gettext library (with "__" suffix).
It is compiled into libintl when the included GNU gettext library is
configured --with-included-gettext.
This redirection works also in the case that the system C library or
the system libintl library contain gettext/textdomain/... functions.
If it didn't, we would need to add preprocessor level redirections to
libgnuintl.h of the following form:
# define gettext gettext__
# define dgettext dgettext__
# define dcgettext dcgettext__
# define ngettext ngettext__
# define dngettext dngettext__
# define dcngettext dcngettext__
# define textdomain textdomain__
# define bindtextdomain bindtextdomain__
# define bind_textdomain_codeset bind_textdomain_codeset__
How does this redirection work? There are two cases.
A. When libintl.a is linked into an executable, it works because
functions defined in the executable always override functions in
the shared libraries.
B. When libintl.so is used, it works because
1. those systems defining gettext/textdomain/... in the C library
(namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer) are
ELF systems and define these symbols as weak, thus explicitly
letting other shared libraries override it.
2. those systems defining gettext/textdomain/... in a standalone
libintl.so library (namely, Solaris 2.3 and newer) have this
shared library in /usr/lib, and the linker will search /usr/lib
*after* the directory where the GNU gettext library is installed.
A third case, namely when libintl.a is linked into a shared library
whose name is not libintl.so, is not supported. In this case, on
Solaris, when -lintl precedes the linker option for the shared library
containing GNU gettext, the system's gettext would indeed override
the GNU gettext. Anyone doing this kind of stuff must be clever enough
to 1. compile libintl.a with -fPIC, 2. remove -lintl from his linker
command line. */
#undef gettext
#undef dgettext
#undef dcgettext
#undef ngettext
#undef dngettext
#undef dcngettext
#undef textdomain
#undef bindtextdomain
#undef bind_textdomain_codeset
char *
gettext (msgid)
const char *msgid;
{
return gettext__ (msgid);
}
char *
dgettext (domainname, msgid)
const char *domainname;
const char *msgid;
{
return dgettext__ (domainname, msgid);
}
char *
dcgettext (domainname, msgid, category)
const char *domainname;
const char *msgid;
int category;
{
return dcgettext__ (domainname, msgid, category);
}
char *
ngettext (msgid1, msgid2, n)
const char *msgid1;
const char *msgid2;
unsigned long int n;
{
return ngettext__ (msgid1, msgid2, n);
}
char *
dngettext (domainname, msgid1, msgid2, n)
const char *domainname;
const char *msgid1;
const char *msgid2;
unsigned long int n;
{
return dngettext__ (domainname, msgid1, msgid2, n);
}
char *
dcngettext (domainname, msgid1, msgid2, n, category)
const char *domainname;
const char *msgid1;
const char *msgid2;
unsigned long int n;
int category;
{
return dcngettext__ (domainname, msgid1, msgid2, n, category);
}
char *
textdomain (domainname)
const char *domainname;
{
return textdomain__ (domainname);
}
char *
bindtextdomain (domainname, dirname)
const char *domainname;
const char *dirname;
{
return bindtextdomain__ (domainname, dirname);
}
char *
bind_textdomain_codeset (domainname, codeset)
const char *domainname;
const char *codeset;
{
return bind_textdomain_codeset__ (domainname, codeset);
}

400
elfutils/intl/l10nflist.c Normal file
View File

@ -0,0 +1,400 @@
/* Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* Tell glibc's <string.h> to provide a prototype for stpcpy().
This must come before <config.h> because <config.h> may include
<features.h>, and once <features.h> has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#if defined _LIBC || defined HAVE_ARGZ_H
# include <argz.h>
#endif
#include <ctype.h>
#include <sys/types.h>
#include <stdlib.h>
#include "loadinfo.h"
/* On some strange systems still no definition of NULL is found. Sigh! */
#ifndef NULL
# if defined __STDC__ && __STDC__
# define NULL ((void *) 0)
# else
# define NULL 0
# endif
#endif
/* @@ end of prolog @@ */
#ifdef _LIBC
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
# ifndef stpcpy
# define stpcpy(dest, src) __stpcpy(dest, src)
# endif
#else
# ifndef HAVE_STPCPY
static char *stpcpy PARAMS ((char *dest, const char *src));
# endif
#endif
/* Define function which are usually not available. */
#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
/* Returns the number of strings in ARGZ. */
static size_t argz_count__ PARAMS ((const char *argz, size_t len));
static size_t
argz_count__ (argz, len)
const char *argz;
size_t len;
{
size_t count = 0;
while (len > 0)
{
size_t part_len = strlen (argz);
argz += part_len + 1;
len -= part_len + 1;
count++;
}
return count;
}
# undef __argz_count
# define __argz_count(argz, len) argz_count__ (argz, len)
#endif /* !_LIBC && !HAVE___ARGZ_COUNT */
#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
except the last into the character SEP. */
static void argz_stringify__ PARAMS ((char *argz, size_t len, int sep));
static void
argz_stringify__ (argz, len, sep)
char *argz;
size_t len;
int sep;
{
while (len > 0)
{
size_t part_len = strlen (argz);
argz += part_len;
len -= part_len + 1;
if (len > 0)
*argz++ = sep;
}
}
# undef __argz_stringify
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
static char *argz_next__ PARAMS ((char *argz, size_t argz_len,
const char *entry));
static char *
argz_next__ (argz, argz_len, entry)
char *argz;
size_t argz_len;
const char *entry;
{
if (entry)
{
if (entry < argz + argz_len)
entry = strchr (entry, '\0') + 1;
return entry >= argz + argz_len ? NULL : (char *) entry;
}
else
if (argz_len > 0)
return argz;
else
return 0;
}
# undef __argz_next
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
#endif /* !_LIBC && !HAVE___ARGZ_NEXT */
/* Return number of bits set in X. */
static int pop PARAMS ((int x));
static inline int
pop (x)
int x;
{
/* We assume that no more than 16 bits are used. */
x = ((x & ~0x5555) >> 1) + (x & 0x5555);
x = ((x & ~0x3333) >> 2) + (x & 0x3333);
x = ((x >> 4) + x) & 0x0f0f;
x = ((x >> 8) + x) & 0xff;
return x;
}
struct loaded_l10nfile *
_nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
territory, codeset, normalized_codeset, modifier, special,
sponsor, revision, filename, do_allocate)
struct loaded_l10nfile **l10nfile_list;
const char *dirlist;
size_t dirlist_len;
int mask;
const char *language;
const char *territory;
const char *codeset;
const char *normalized_codeset;
const char *modifier;
const char *special;
const char *sponsor;
const char *revision;
const char *filename;
int do_allocate;
{
char *abs_filename;
struct loaded_l10nfile *last = NULL;
struct loaded_l10nfile *retval;
char *cp;
size_t entries;
int cnt;
/* Allocate room for the full file name. */
abs_filename = (char *) malloc (dirlist_len
+ strlen (language)
+ ((mask & TERRITORY) != 0
? strlen (territory) + 1 : 0)
+ ((mask & XPG_CODESET) != 0
? strlen (codeset) + 1 : 0)
+ ((mask & XPG_NORM_CODESET) != 0
? strlen (normalized_codeset) + 1 : 0)
+ (((mask & XPG_MODIFIER) != 0
|| (mask & CEN_AUDIENCE) != 0)
? strlen (modifier) + 1 : 0)
+ ((mask & CEN_SPECIAL) != 0
? strlen (special) + 1 : 0)
+ (((mask & CEN_SPONSOR) != 0
|| (mask & CEN_REVISION) != 0)
? (1 + ((mask & CEN_SPONSOR) != 0
? strlen (sponsor) + 1 : 0)
+ ((mask & CEN_REVISION) != 0
? strlen (revision) + 1 : 0)) : 0)
+ 1 + strlen (filename) + 1);
if (abs_filename == NULL)
return NULL;
retval = NULL;
last = NULL;
/* Construct file name. */
memcpy (abs_filename, dirlist, dirlist_len);
__argz_stringify (abs_filename, dirlist_len, PATH_SEPARATOR);
cp = abs_filename + (dirlist_len - 1);
*cp++ = '/';
cp = stpcpy (cp, language);
if ((mask & TERRITORY) != 0)
{
*cp++ = '_';
cp = stpcpy (cp, territory);
}
if ((mask & XPG_CODESET) != 0)
{
*cp++ = '.';
cp = stpcpy (cp, codeset);
}
if ((mask & XPG_NORM_CODESET) != 0)
{
*cp++ = '.';
cp = stpcpy (cp, normalized_codeset);
}
if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
{
/* This component can be part of both syntaces but has different
leading characters. For CEN we use `+', else `@'. */
*cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
cp = stpcpy (cp, modifier);
}
if ((mask & CEN_SPECIAL) != 0)
{
*cp++ = '+';
cp = stpcpy (cp, special);
}
if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
{
*cp++ = ',';
if ((mask & CEN_SPONSOR) != 0)
cp = stpcpy (cp, sponsor);
if ((mask & CEN_REVISION) != 0)
{
*cp++ = '_';
cp = stpcpy (cp, revision);
}
}
*cp++ = '/';
stpcpy (cp, filename);
/* Look in list of already loaded domains whether it is already
available. */
last = NULL;
for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
if (retval->filename != NULL)
{
int compare = strcmp (retval->filename, abs_filename);
if (compare == 0)
/* We found it! */
break;
if (compare < 0)
{
/* It's not in the list. */
retval = NULL;
break;
}
last = retval;
}
if (retval != NULL || do_allocate == 0)
{
free (abs_filename);
return retval;
}
retval = (struct loaded_l10nfile *)
malloc (sizeof (*retval) + (__argz_count (dirlist, dirlist_len)
* (1 << pop (mask))
* sizeof (struct loaded_l10nfile *)));
if (retval == NULL)
return NULL;
retval->filename = abs_filename;
retval->decided = (__argz_count (dirlist, dirlist_len) != 1
|| ((mask & XPG_CODESET) != 0
&& (mask & XPG_NORM_CODESET) != 0));
retval->data = NULL;
if (last == NULL)
{
retval->next = *l10nfile_list;
*l10nfile_list = retval;
}
else
{
retval->next = last->next;
last->next = retval;
}
entries = 0;
/* If the DIRLIST is a real list the RETVAL entry corresponds not to
a real file. So we have to use the DIRLIST separation mechanism
of the inner loop. */
cnt = __argz_count (dirlist, dirlist_len) == 1 ? mask - 1 : mask;
for (; cnt >= 0; --cnt)
if ((cnt & ~mask) == 0
&& ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
&& ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
{
/* Iterate over all elements of the DIRLIST. */
char *dir = NULL;
while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
!= NULL)
retval->successor[entries++]
= _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt,
language, territory, codeset,
normalized_codeset, modifier, special,
sponsor, revision, filename, 1);
}
retval->successor[entries] = NULL;
return retval;
}
/* Normalize codeset name. There is no standard for the codeset
names. Normalization allows the user to use any of the common
names. The return value is dynamically allocated and has to be
freed by the caller. */
const char *
_nl_normalize_codeset (codeset, name_len)
const char *codeset;
size_t name_len;
{
int len = 0;
int only_digit = 1;
char *retval;
char *wp;
size_t cnt;
for (cnt = 0; cnt < name_len; ++cnt)
if (isalnum ((unsigned char) codeset[cnt]))
{
++len;
if (isalpha ((unsigned char) codeset[cnt]))
only_digit = 0;
}
retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
if (retval != NULL)
{
if (only_digit)
wp = stpcpy (retval, "iso");
else
wp = retval;
for (cnt = 0; cnt < name_len; ++cnt)
if (isalpha ((unsigned char) codeset[cnt]))
*wp++ = tolower ((unsigned char) codeset[cnt]);
else if (isdigit ((unsigned char) codeset[cnt]))
*wp++ = codeset[cnt];
*wp = '\0';
}
return (const char *) retval;
}
/* @@ begin of epilog @@ */
/* We don't want libintl.a to depend on any other library. So we
avoid the non-standard function stpcpy. In GNU C Library this
function is available, though. Also allow the symbol HAVE_STPCPY
to be defined. */
#if !_LIBC && !HAVE_STPCPY
static char *
stpcpy (dest, src)
char *dest;
const char *src;
{
while ((*dest++ = *src++) != '\0')
/* Do nothing. */ ;
return dest - 1;
}
#endif

137
elfutils/intl/libgnuintl.h Normal file
View File

@ -0,0 +1,137 @@
/* Message catalogs for internationalization.
Copyright (C) 1995-1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _LIBINTL_H
#define _LIBINTL_H 1
#include <locale.h>
/* The LC_MESSAGES locale category is the category used by the functions
gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
On systems that don't define it, use an arbitrary value instead.
On Solaris, <locale.h> defines __LOCALE_H then includes <libintl.h> (i.e.
this file!) and then only defines LC_MESSAGES. To avoid a redefinition
warning, don't define LC_MESSAGES in this case. */
#if !defined LC_MESSAGES && !defined __LOCALE_H
# define LC_MESSAGES 1729
#endif
/* We define an additional symbol to signal that we use the GNU
implementation of gettext. */
#define __USE_GNU_GETTEXT 1
/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
precedence over _conio_gettext. */
#ifdef __DJGPP__
# undef gettext
# define gettext gettext
#endif
/* Use _INTL_PARAMS, not PARAMS, in order to avoid clashes with identifiers
used by programs. Similarly, test __PROTOTYPES, not PROTOTYPES. */
#ifndef _INTL_PARAMS
# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
# define _INTL_PARAMS(args) args
# else
# define _INTL_PARAMS(args) ()
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
extern char *gettext _INTL_PARAMS ((const char *__msgid));
/* Look up MSGID in the DOMAINNAME message catalog for the current
LC_MESSAGES locale. */
extern char *dgettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid));
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
extern char *dcgettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid,
int __category));
/* Similar to `gettext' but select the plural form corresponding to the
number N. */
extern char *ngettext _INTL_PARAMS ((const char *__msgid1,
const char *__msgid2,
unsigned long int __n));
/* Similar to `dgettext' but select the plural form corresponding to the
number N. */
extern char *dngettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid1,
const char *__msgid2,
unsigned long int __n));
/* Similar to `dcgettext' but select the plural form corresponding to the
number N. */
extern char *dcngettext _INTL_PARAMS ((const char *__domainname,
const char *__msgid1,
const char *__msgid2,
unsigned long int __n,
int __category));
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
extern char *textdomain _INTL_PARAMS ((const char *__domainname));
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
extern char *bindtextdomain _INTL_PARAMS ((const char *__domainname,
const char *__dirname));
/* Specify the character encoding in which the messages from the
DOMAINNAME message catalog will be returned. */
extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname,
const char *__codeset));
/* Optimized version of the functions above. */
#if defined __OPTIMIZED
/* These are macros, but could also be inline functions. */
# define gettext(msgid) \
dgettext (NULL, msgid)
# define dgettext(domainname, msgid) \
dcgettext (domainname, msgid, LC_MESSAGES)
# define ngettext(msgid1, msgid2, n) \
dngettext (NULL, msgid1, msgid2, n)
# define dngettext(domainname, msgid1, msgid2, n) \
dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES)
#endif /* Optimizing. */
#ifdef __cplusplus
}
#endif
#endif /* libintl.h */

121
elfutils/intl/loadinfo.h Normal file
View File

@ -0,0 +1,121 @@
/* Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _LOADINFO_H
#define _LOADINFO_H 1
/* Declarations of locale dependent catalog lookup functions.
Implemented in
localealias.c Possibly replace a locale name by another.
explodename.c Split a locale name into its various fields.
l10nflist.c Generate a list of filenames of possible message catalogs.
finddomain.c Find and open the relevant message catalogs.
The main function _nl_find_domain() in finddomain.c is declared
in gettextP.h.
*/
#ifndef PARAMS
# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif
#endif
#ifndef internal_function
# define internal_function
#endif
/* Tell the compiler when a conditional or integer expression is
almost always true or almost always false. */
#ifndef HAVE_BUILTIN_EXPECT
# define __builtin_expect(expr, val) (expr)
#endif
/* Separator in PATH like lists of pathnames. */
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
/* Win32, OS/2, DOS */
# define PATH_SEPARATOR ';'
#else
/* Unix */
# define PATH_SEPARATOR ':'
#endif
/* Encoding of locale name parts. */
#define CEN_REVISION 1
#define CEN_SPONSOR 2
#define CEN_SPECIAL 4
#define XPG_NORM_CODESET 8
#define XPG_CODESET 16
#define TERRITORY 32
#define CEN_AUDIENCE 64
#define XPG_MODIFIER 128
#define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE)
#define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER)
struct loaded_l10nfile
{
const char *filename;
int decided;
const void *data;
struct loaded_l10nfile *next;
struct loaded_l10nfile *successor[1];
};
/* Normalize codeset name. There is no standard for the codeset
names. Normalization allows the user to use any of the common
names. The return value is dynamically allocated and has to be
freed by the caller. */
extern const char *_nl_normalize_codeset PARAMS ((const char *codeset,
size_t name_len));
extern struct loaded_l10nfile *
_nl_make_l10nflist PARAMS ((struct loaded_l10nfile **l10nfile_list,
const char *dirlist, size_t dirlist_len, int mask,
const char *language, const char *territory,
const char *codeset,
const char *normalized_codeset,
const char *modifier, const char *special,
const char *sponsor, const char *revision,
const char *filename, int do_allocate));
extern const char *_nl_expand_alias PARAMS ((const char *name));
/* normalized_codeset is dynamically allocated and has to be freed by
the caller. */
extern int _nl_explode_name PARAMS ((char *name, const char **language,
const char **modifier,
const char **territory,
const char **codeset,
const char **normalized_codeset,
const char **special,
const char **sponsor,
const char **revision));
extern char *_nl_find_language PARAMS ((const char *name));
#endif /* loadinfo.h */

445
elfutils/intl/loadmsgcat.c Normal file
View File

@ -0,0 +1,445 @@
/* Load needed message catalogs.
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* Tell glibc's <string.h> to provide a prototype for mempcpy().
This must come before <config.h> because <config.h> may include
<features.h>, and once <features.h> has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
# if defined HAVE_ALLOCA_H || defined _LIBC
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
#endif
#include <stdlib.h>
#include <string.h>
#if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h>
#endif
#ifdef _LIBC
# include <langinfo.h>
# include <locale.h>
#endif
#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
|| (defined _LIBC && defined _POSIX_MAPPED_FILES)
# include <sys/mman.h>
# undef HAVE_MMAP
# define HAVE_MMAP 1
#else
# undef HAVE_MMAP
#endif
#include "gmo.h"
#include "gettextP.h"
#include "plural-exp.h"
#ifdef _LIBC
# include "../locale/localeinfo.h"
#endif
/* @@ end of prolog @@ */
#ifdef _LIBC
/* Rename the non ISO C functions. This is required by the standard
because some ISO C functions will require linking with this object
file and the name space must not be polluted. */
# define open __open
# define close __close
# define read __read
# define mmap __mmap
# define munmap __munmap
#endif
/* For those losing systems which don't have `alloca' we have to add
some additional code emulating it. */
#ifdef HAVE_ALLOCA
# define freea(p) /* nothing */
#else
# define alloca(n) malloc (n)
# define freea(p) free (p)
#endif
/* For systems that distinguish between text and binary I/O.
O_BINARY is usually declared in <fcntl.h>. */
#if !defined O_BINARY && defined _O_BINARY
/* For MSC-compatible compilers. */
# define O_BINARY _O_BINARY
# define O_TEXT _O_TEXT
#endif
#ifdef __BEOS__
/* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */
# undef O_BINARY
# undef O_TEXT
#endif
/* On reasonable systems, binary I/O is the default. */
#ifndef O_BINARY
# define O_BINARY 0
#endif
/* We need a sign, whether a new catalog was loaded, which can be associated
with all translations. This is important if the translations are
cached by one of GCC's features. */
int _nl_msg_cat_cntr;
/* Initialize the codeset dependent parts of an opened message catalog.
Return the header entry. */
const char *
internal_function
_nl_init_domain_conv (domain_file, domain, domainbinding)
struct loaded_l10nfile *domain_file;
struct loaded_domain *domain;
struct binding *domainbinding;
{
/* Find out about the character set the file is encoded with.
This can be found (in textual form) in the entry "". If this
entry does not exist or if this does not contain the `charset='
information, we will assume the charset matches the one the
current locale and we don't have to perform any conversion. */
char *nullentry;
size_t nullentrylen;
/* Preinitialize fields, to avoid recursion during _nl_find_msg. */
domain->codeset_cntr =
(domainbinding != NULL ? domainbinding->codeset_cntr : 0);
#ifdef _LIBC
domain->conv = (__gconv_t) -1;
#else
# if HAVE_ICONV
domain->conv = (iconv_t) -1;
# endif
#endif
domain->conv_tab = NULL;
/* Get the header entry. */
nullentry = _nl_find_msg (domain_file, domainbinding, "", &nullentrylen);
if (nullentry != NULL)
{
#if defined _LIBC || HAVE_ICONV
const char *charsetstr;
charsetstr = strstr (nullentry, "charset=");
if (charsetstr != NULL)
{
size_t len;
char *charset;
const char *outcharset;
charsetstr += strlen ("charset=");
len = strcspn (charsetstr, " \t\n");
charset = (char *) alloca (len + 1);
# if defined _LIBC || HAVE_MEMPCPY
*((char *) mempcpy (charset, charsetstr, len)) = '\0';
# else
memcpy (charset, charsetstr, len);
charset[len] = '\0';
# endif
/* The output charset should normally be determined by the
locale. But sometimes the locale is not used or not correctly
set up, so we provide a possibility for the user to override
this. Moreover, the value specified through
bind_textdomain_codeset overrides both. */
if (domainbinding != NULL && domainbinding->codeset != NULL)
outcharset = domainbinding->codeset;
else
{
outcharset = getenv ("OUTPUT_CHARSET");
if (outcharset == NULL || outcharset[0] == '\0')
{
# ifdef _LIBC
outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string;
# else
# if HAVE_ICONV
extern const char *locale_charset PARAMS ((void));
outcharset = locale_charset ();
# endif
# endif
}
}
# ifdef _LIBC
/* We always want to use transliteration. */
outcharset = norm_add_slashes (outcharset, "TRANSLIT");
charset = norm_add_slashes (charset, NULL);
if (__gconv_open (outcharset, charset, &domain->conv,
GCONV_AVOID_NOCONV)
!= __GCONV_OK)
domain->conv = (__gconv_t) -1;
# else
# if HAVE_ICONV
/* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
we want to use transliteration. */
# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
|| _LIBICONV_VERSION >= 0x0105
len = strlen (outcharset);
{
char *tmp = (char *) alloca (len + 10 + 1);
memcpy (tmp, outcharset, len);
memcpy (tmp + len, "//TRANSLIT", 10 + 1);
outcharset = tmp;
}
# endif
domain->conv = iconv_open (outcharset, charset);
# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
|| _LIBICONV_VERSION >= 0x0105
freea (outcharset);
# endif
# endif
# endif
freea (charset);
}
#endif /* _LIBC || HAVE_ICONV */
}
return nullentry;
}
/* Frees the codeset dependent parts of an opened message catalog. */
void
internal_function
_nl_free_domain_conv (domain)
struct loaded_domain *domain;
{
if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1)
free (domain->conv_tab);
#ifdef _LIBC
if (domain->conv != (__gconv_t) -1)
__gconv_close (domain->conv);
#else
# if HAVE_ICONV
if (domain->conv != (iconv_t) -1)
iconv_close (domain->conv);
# endif
#endif
}
/* Load the message catalogs specified by FILENAME. If it is no valid
message catalog do nothing. */
void
internal_function
_nl_load_domain (domain_file, domainbinding)
struct loaded_l10nfile *domain_file;
struct binding *domainbinding;
{
int fd;
size_t size;
#ifdef _LIBC
struct stat64 st;
#else
struct stat st;
#endif
struct mo_file_header *data = (struct mo_file_header *) -1;
int use_mmap = 0;
struct loaded_domain *domain;
const char *nullentry;
domain_file->decided = 1;
domain_file->data = NULL;
/* Note that it would be useless to store domainbinding in domain_file
because domainbinding might be == NULL now but != NULL later (after
a call to bind_textdomain_codeset). */
/* If the record does not represent a valid locale the FILENAME
might be NULL. This can happen when according to the given
specification the locale file name is different for XPG and CEN
syntax. */
if (domain_file->filename == NULL)
return;
/* Try to open the addressed file. */
fd = open (domain_file->filename, O_RDONLY | O_BINARY);
if (fd == -1)
return;
/* We must know about the size of the file. */
if (
#ifdef _LIBC
__builtin_expect (fstat64 (fd, &st) != 0, 0)
#else
__builtin_expect (fstat (fd, &st) != 0, 0)
#endif
|| __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
|| __builtin_expect (size < sizeof (struct mo_file_header), 0))
{
/* Something went wrong. */
close (fd);
return;
}
#ifdef HAVE_MMAP
/* Now we are ready to load the file. If mmap() is available we try
this first. If not available or it failed we try to load it. */
data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
MAP_PRIVATE, fd, 0);
if (__builtin_expect (data != (struct mo_file_header *) -1, 1))
{
/* mmap() call was successful. */
close (fd);
use_mmap = 1;
}
#endif
/* If the data is not yet available (i.e. mmap'ed) we try to load
it manually. */
if (data == (struct mo_file_header *) -1)
{
size_t to_read;
char *read_ptr;
data = (struct mo_file_header *) malloc (size);
if (data == NULL)
return;
to_read = size;
read_ptr = (char *) data;
do
{
long int nb = (long int) read (fd, read_ptr, to_read);
if (nb <= 0)
{
#ifdef EINTR
if (nb == -1 && errno == EINTR)
continue;
#endif
close (fd);
return;
}
read_ptr += nb;
to_read -= nb;
}
while (to_read > 0);
close (fd);
}
/* Using the magic number we can test whether it really is a message
catalog file. */
if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED,
0))
{
/* The magic number is wrong: not a message catalog file. */
#ifdef HAVE_MMAP
if (use_mmap)
munmap ((caddr_t) data, size);
else
#endif
free (data);
return;
}
domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain));
if (domain == NULL)
return;
domain_file->data = domain;
domain->data = (char *) data;
domain->use_mmap = use_mmap;
domain->mmap_size = size;
domain->must_swap = data->magic != _MAGIC;
/* Fill in the information about the available tables. */
switch (W (domain->must_swap, data->revision))
{
case 0:
domain->nstrings = W (domain->must_swap, data->nstrings);
domain->orig_tab = (struct string_desc *)
((char *) data + W (domain->must_swap, data->orig_tab_offset));
domain->trans_tab = (struct string_desc *)
((char *) data + W (domain->must_swap, data->trans_tab_offset));
domain->hash_size = W (domain->must_swap, data->hash_tab_size);
domain->hash_tab = (nls_uint32 *)
((char *) data + W (domain->must_swap, data->hash_tab_offset));
break;
default:
/* This is an invalid revision. */
#ifdef HAVE_MMAP
if (use_mmap)
munmap ((caddr_t) data, size);
else
#endif
free (data);
free (domain);
domain_file->data = NULL;
return;
}
/* Now initialize the character set converter from the character set
the file is encoded with (found in the header entry) to the domain's
specified character set or the locale's character set. */
nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding);
/* Also look for a plural specification. */
EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
}
#ifdef _LIBC
void
internal_function
_nl_unload_domain (domain)
struct loaded_domain *domain;
{
if (domain->plural != &__gettext_germanic_plural)
__gettext_free_exp (domain->plural);
_nl_free_domain_conv (domain);
# ifdef _POSIX_MAPPED_FILES
if (domain->use_mmap)
munmap ((caddr_t) domain->data, domain->mmap_size);
else
# endif /* _POSIX_MAPPED_FILES */
free ((void *) domain->data);
free (domain);
}
#endif

View File

@ -0,0 +1,345 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* Written by Bruno Haible <haible@clisp.cons.org>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_STDDEF_H
# include <stddef.h>
#endif
#include <stdio.h>
#if HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if defined _WIN32 || defined __WIN32__
# undef WIN32 /* avoid warning on mingw32 */
# define WIN32
#endif
#if defined __EMX__
/* Assume EMX program runs on OS/2, even if compiled under DOS. */
# define OS2
#endif
#if !defined WIN32
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# else
# if HAVE_SETLOCALE
# include <locale.h>
# endif
# endif
#elif defined WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
#if defined OS2
# define INCL_DOS
# include <os2.h>
#endif
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
/* Win32, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
#endif
#ifndef DIRECTORY_SEPARATOR
# define DIRECTORY_SEPARATOR '/'
#endif
#ifndef ISSLASH
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
#endif
#ifdef HAVE_GETC_UNLOCKED
# undef getc
# define getc getc_unlocked
#endif
/* The following static variable is declared 'volatile' to avoid a
possible multithread problem in the function get_charset_aliases. If we
are running in a threaded environment, and if two threads initialize
'charset_aliases' simultaneously, both will produce the same value,
and everything will be ok if the two assignments to 'charset_aliases'
are atomic. But I don't know what will happen if the two assignments mix. */
#if __STDC__ != 1
# define volatile /* empty */
#endif
/* Pointer to the contents of the charset.alias file, if it has already been
read, else NULL. Its format is:
ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
static const char * volatile charset_aliases;
/* Return a pointer to the contents of the charset.alias file. */
static const char *
get_charset_aliases ()
{
const char *cp;
cp = charset_aliases;
if (cp == NULL)
{
#if !defined WIN32
FILE *fp;
const char *dir = LIBDIR;
const char *base = "charset.alias";
char *file_name;
/* Concatenate dir and base into freshly allocated file_name. */
{
size_t dir_len = strlen (dir);
size_t base_len = strlen (base);
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
if (file_name != NULL)
{
memcpy (file_name, dir, dir_len);
if (add_slash)
file_name[dir_len] = DIRECTORY_SEPARATOR;
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
}
}
if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
/* Out of memory or file not found, treat it as empty. */
cp = "";
else
{
/* Parse the file's contents. */
int c;
char buf1[50+1];
char buf2[50+1];
char *res_ptr = NULL;
size_t res_size = 0;
size_t l1, l2;
for (;;)
{
c = getc (fp);
if (c == EOF)
break;
if (c == '\n' || c == ' ' || c == '\t')
continue;
if (c == '#')
{
/* Skip comment, to end of line. */
do
c = getc (fp);
while (!(c == EOF || c == '\n'));
if (c == EOF)
break;
continue;
}
ungetc (c, fp);
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
break;
l1 = strlen (buf1);
l2 = strlen (buf2);
if (res_size == 0)
{
res_size = l1 + 1 + l2 + 1;
res_ptr = (char *) malloc (res_size + 1);
}
else
{
res_size += l1 + 1 + l2 + 1;
res_ptr = (char *) realloc (res_ptr, res_size + 1);
}
if (res_ptr == NULL)
{
/* Out of memory. */
res_size = 0;
break;
}
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
strcpy (res_ptr + res_size - (l2 + 1), buf2);
}
fclose (fp);
if (res_size == 0)
cp = "";
else
{
*(res_ptr + res_size) = '\0';
cp = res_ptr;
}
}
if (file_name != NULL)
free (file_name);
#else
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
# if defined WIN32
cp = "CP936" "\0" "GBK" "\0"
"CP1361" "\0" "JOHAB" "\0";
# endif
#endif
charset_aliases = cp;
}
return cp;
}
/* Determine the current locale's character encoding, and canonicalize it
into one of the canonical names listed in config.charset.
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
#ifdef STATIC
STATIC
#endif
const char *
locale_charset ()
{
const char *codeset;
const char *aliases;
#if !(defined WIN32 || defined OS2)
# if HAVE_LANGINFO_CODESET
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
# else
/* On old systems which lack it, use setlocale or getenv. */
const char *locale = NULL;
/* But most old systems don't have a complete set of locales. Some
(like SunOS 4 or DJGPP) have only the C locale. Therefore we don't
use setlocale here; it would return "C" when it doesn't support the
locale name the user has set. */
# if HAVE_SETLOCALE && 0
locale = setlocale (LC_CTYPE, NULL);
# endif
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG");
}
}
/* On some old systems, one used to set locale = "iso8859_1". On others,
you set it to "language_COUNTRY.charset". In any case, we resolve it
through the charset.alias file. */
codeset = locale;
# endif
#elif defined WIN32
static char buf[2 + 10 + 1];
/* Win32 has a function returning the locale's codepage as a number. */
sprintf (buf, "CP%u", GetACP ());
codeset = buf;
#elif defined OS2
const char *locale;
static char buf[2 + 10 + 1];
ULONG cp[3];
ULONG cplen;
/* Allow user to override the codeset, as set in the operating system,
with standard language environment variables. */
locale = getenv ("LC_ALL");
if (locale == NULL || locale[0] == '\0')
{
locale = getenv ("LC_CTYPE");
if (locale == NULL || locale[0] == '\0')
locale = getenv ("LANG");
}
if (locale != NULL && locale[0] != '\0')
{
/* If the locale name contains an encoding after the dot, return it. */
const char *dot = strchr (locale, '.');
if (dot != NULL)
{
const char *modifier;
dot++;
/* Look for the possible @... trailer and remove it, if any. */
modifier = strchr (dot, '@');
if (modifier == NULL)
return dot;
if (modifier - dot < sizeof (buf))
{
memcpy (buf, dot, modifier - dot);
buf [modifier - dot] = '\0';
return buf;
}
}
/* Resolve through the charset.alias file. */
codeset = locale;
}
else
{
/* OS/2 has a function returning the locale's codepage as a number. */
if (DosQueryCp (sizeof (cp), cp, &cplen))
codeset = "";
else
{
sprintf (buf, "CP%u", cp[0]);
codeset = buf;
}
}
#endif
if (codeset == NULL)
/* The canonical name cannot be determined. */
codeset = "";
/* Resolve alias. */
for (aliases = get_charset_aliases ();
*aliases != '\0';
aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
if (strcmp (codeset, aliases) == 0
|| (aliases[0] == '*' && aliases[1] == '\0'))
{
codeset = aliases + strlen (aliases) + 1;
break;
}
return codeset;
}

View File

@ -0,0 +1,78 @@
# Locale name alias data base.
# Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
# The format of this file is the same as for the corresponding file of
# the X Window System, which normally can be found in
# /usr/lib/X11/locale/locale.alias
# A single line contains two fields: an alias and a substitution value.
# All entries are case independent.
# Note: This file is far from being complete. If you have a value for
# your own site which you think might be useful for others too, share
# it with the rest of us. Send it using the `glibcbug' script to
# bugs@gnu.org.
# Packages using this file:
bokmal no_NO.ISO-8859-1
bokmål no_NO.ISO-8859-1
catalan ca_ES.ISO-8859-1
croatian hr_HR.ISO-8859-2
czech cs_CZ.ISO-8859-2
danish da_DK.ISO-8859-1
dansk da_DK.ISO-8859-1
deutsch de_DE.ISO-8859-1
dutch nl_NL.ISO-8859-1
eesti et_EE.ISO-8859-1
estonian et_EE.ISO-8859-1
finnish fi_FI.ISO-8859-1
français fr_FR.ISO-8859-1
french fr_FR.ISO-8859-1
galego gl_ES.ISO-8859-1
galician gl_ES.ISO-8859-1
german de_DE.ISO-8859-1
greek el_GR.ISO-8859-7
hebrew he_IL.ISO-8859-8
hrvatski hr_HR.ISO-8859-2
hungarian hu_HU.ISO-8859-2
icelandic is_IS.ISO-8859-1
italian it_IT.ISO-8859-1
japanese ja_JP.eucJP
japanese.euc ja_JP.eucJP
ja_JP ja_JP.eucJP
ja_JP.ujis ja_JP.eucJP
japanese.sjis ja_JP.SJIS
korean ko_KR.eucKR
korean.euc ko_KR.eucKR
ko_KR ko_KR.eucKR
lithuanian lt_LT.ISO-8859-13
nb_NO no_NO.ISO-8859-1
nb_NO.ISO-8859-1 no_NO.ISO-8859-1
norwegian no_NO.ISO-8859-1
nynorsk nn_NO.ISO-8859-1
polish pl_PL.ISO-8859-2
portuguese pt_PT.ISO-8859-1
romanian ro_RO.ISO-8859-2
russian ru_RU.ISO-8859-5
slovak sk_SK.ISO-8859-2
slovene sl_SI.ISO-8859-2
slovenian sl_SI.ISO-8859-2
spanish es_ES.ISO-8859-1
swedish sv_SE.ISO-8859-1
thai th_TH.TIS-620
turkish tr_TR.ISO-8859-9

419
elfutils/intl/localealias.c Normal file
View File

@ -0,0 +1,419 @@
/* Handle aliases for locale names.
Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* Tell glibc's <string.h> to provide a prototype for mempcpy().
This must come before <config.h> because <config.h> may include
<features.h>, and once <features.h> has been included, it's too late. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#include <stdio.h>
#if defined _LIBC || defined HAVE___FSETLOCKING
# include <stdio_ext.h>
#endif
#include <sys/types.h>
#ifdef __GNUC__
# define alloca __builtin_alloca
# define HAVE_ALLOCA 1
#else
# if defined HAVE_ALLOCA_H || defined _LIBC
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
#endif
#include <stdlib.h>
#include <string.h>
#include "gettextP.h"
/* @@ end of prolog @@ */
#ifdef _LIBC
/* Rename the non ANSI C functions. This is required by the standard
because some ANSI C functions will require linking with this object
file and the name space must not be polluted. */
# define strcasecmp __strcasecmp
# ifndef mempcpy
# define mempcpy __mempcpy
# endif
# define HAVE_MEMPCPY 1
# define HAVE___FSETLOCKING 1
/* We need locking here since we can be called from different places. */
# include <bits/libc-lock.h>
__libc_lock_define_initialized (static, lock);
#endif
#ifndef internal_function
# define internal_function
#endif
/* Some optimizations for glibc. */
#ifdef _LIBC
# define FEOF(fp) feof_unlocked (fp)
# define FGETS(buf, n, fp) fgets_unlocked (buf, n, fp)
#else
# define FEOF(fp) feof (fp)
# define FGETS(buf, n, fp) fgets (buf, n, fp)
#endif
/* For those losing systems which don't have `alloca' we have to add
some additional code emulating it. */
#ifdef HAVE_ALLOCA
# define freea(p) /* nothing */
#else
# define alloca(n) malloc (n)
# define freea(p) free (p)
#endif
#if defined _LIBC_REENTRANT || defined HAVE_FGETS_UNLOCKED
# undef fgets
# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
#endif
#if defined _LIBC_REENTRANT || defined HAVE_FEOF_UNLOCKED
# undef feof
# define feof(s) feof_unlocked (s)
#endif
struct alias_map
{
const char *alias;
const char *value;
};
static char *string_space;
static size_t string_space_act;
static size_t string_space_max;
static struct alias_map *map;
static size_t nmap;
static size_t maxmap;
/* Prototypes for local functions. */
static size_t read_alias_file PARAMS ((const char *fname, int fname_len))
internal_function;
static int extend_alias_table PARAMS ((void));
static int alias_compare PARAMS ((const struct alias_map *map1,
const struct alias_map *map2));
const char *
_nl_expand_alias (name)
const char *name;
{
static const char *locale_alias_path;
struct alias_map *retval;
const char *result = NULL;
size_t added;
#ifdef _LIBC
__libc_lock_lock (lock);
#endif
if (locale_alias_path == NULL)
locale_alias_path = LOCALE_ALIAS_PATH;
do
{
struct alias_map item;
item.alias = name;
if (nmap > 0)
retval = (struct alias_map *) bsearch (&item, map, nmap,
sizeof (struct alias_map),
(int (*) PARAMS ((const void *,
const void *))
) alias_compare);
else
retval = NULL;
/* We really found an alias. Return the value. */
if (retval != NULL)
{
result = retval->value;
break;
}
/* Perhaps we can find another alias file. */
added = 0;
while (added == 0 && locale_alias_path[0] != '\0')
{
const char *start;
while (locale_alias_path[0] == PATH_SEPARATOR)
++locale_alias_path;
start = locale_alias_path;
while (locale_alias_path[0] != '\0'
&& locale_alias_path[0] != PATH_SEPARATOR)
++locale_alias_path;
if (start < locale_alias_path)
added = read_alias_file (start, locale_alias_path - start);
}
}
while (added != 0);
#ifdef _LIBC
__libc_lock_unlock (lock);
#endif
return result;
}
static size_t
internal_function
read_alias_file (fname, fname_len)
const char *fname;
int fname_len;
{
FILE *fp;
char *full_fname;
size_t added;
static const char aliasfile[] = "/locale.alias";
full_fname = (char *) alloca (fname_len + sizeof aliasfile);
#ifdef HAVE_MEMPCPY
mempcpy (mempcpy (full_fname, fname, fname_len),
aliasfile, sizeof aliasfile);
#else
memcpy (full_fname, fname, fname_len);
memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
#endif
fp = fopen (full_fname, "r");
freea (full_fname);
if (fp == NULL)
return 0;
#ifdef HAVE___FSETLOCKING
/* No threads present. */
__fsetlocking (fp, FSETLOCKING_BYCALLER);
#endif
added = 0;
while (!FEOF (fp))
{
/* It is a reasonable approach to use a fix buffer here because
a) we are only interested in the first two fields
b) these fields must be usable as file names and so must not
be that long
*/
char buf[BUFSIZ];
char *alias;
char *value;
char *cp;
if (FGETS (buf, sizeof buf, fp) == NULL)
/* EOF reached. */
break;
/* Possibly not the whole line fits into the buffer. Ignore
the rest of the line. */
if (strchr (buf, '\n') == NULL)
{
char altbuf[BUFSIZ];
do
if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
/* Make sure the inner loop will be left. The outer loop
will exit at the `feof' test. */
break;
while (strchr (altbuf, '\n') == NULL);
}
cp = buf;
/* Ignore leading white space. */
while (isspace ((unsigned char) cp[0]))
++cp;
/* A leading '#' signals a comment line. */
if (cp[0] != '\0' && cp[0] != '#')
{
alias = cp++;
while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
++cp;
/* Terminate alias name. */
if (cp[0] != '\0')
*cp++ = '\0';
/* Now look for the beginning of the value. */
while (isspace ((unsigned char) cp[0]))
++cp;
if (cp[0] != '\0')
{
size_t alias_len;
size_t value_len;
value = cp++;
while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
++cp;
/* Terminate value. */
if (cp[0] == '\n')
{
/* This has to be done to make the following test
for the end of line possible. We are looking for
the terminating '\n' which do not overwrite here. */
*cp++ = '\0';
*cp = '\n';
}
else if (cp[0] != '\0')
*cp++ = '\0';
if (nmap >= maxmap)
if (__builtin_expect (extend_alias_table (), 0))
return added;
alias_len = strlen (alias) + 1;
value_len = strlen (value) + 1;
if (string_space_act + alias_len + value_len > string_space_max)
{
/* Increase size of memory pool. */
size_t new_size = (string_space_max
+ (alias_len + value_len > 1024
? alias_len + value_len : 1024));
char *new_pool = (char *) realloc (string_space, new_size);
if (new_pool == NULL)
return added;
if (__builtin_expect (string_space != new_pool, 0))
{
size_t i;
for (i = 0; i < nmap; i++)
{
map[i].alias += new_pool - string_space;
map[i].value += new_pool - string_space;
}
}
string_space = new_pool;
string_space_max = new_size;
}
map[nmap].alias = memcpy (&string_space[string_space_act],
alias, alias_len);
string_space_act += alias_len;
map[nmap].value = memcpy (&string_space[string_space_act],
value, value_len);
string_space_act += value_len;
++nmap;
++added;
}
}
}
/* Should we test for ferror()? I think we have to silently ignore
errors. --drepper */
fclose (fp);
if (added > 0)
qsort (map, nmap, sizeof (struct alias_map),
(int (*) PARAMS ((const void *, const void *))) alias_compare);
return added;
}
static int
extend_alias_table ()
{
size_t new_size;
struct alias_map *new_map;
new_size = maxmap == 0 ? 100 : 2 * maxmap;
new_map = (struct alias_map *) realloc (map, (new_size
* sizeof (struct alias_map)));
if (new_map == NULL)
/* Simply don't extend: we don't have any more core. */
return -1;
map = new_map;
maxmap = new_size;
return 0;
}
#ifdef _LIBC
static void __attribute__ ((unused))
free_mem (void)
{
if (string_space != NULL)
free (string_space);
if (map != NULL)
free (map);
}
text_set_element (__libc_subfreeres, free_mem);
#endif
static int
alias_compare (map1, map2)
const struct alias_map *map1;
const struct alias_map *map2;
{
#if defined _LIBC || defined HAVE_STRCASECMP
return strcasecmp (map1->alias, map2->alias);
#else
const unsigned char *p1 = (const unsigned char *) map1->alias;
const unsigned char *p2 = (const unsigned char *) map2->alias;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
{
/* I know this seems to be odd but the tolower() function in
some systems libc cannot handle nonalpha characters. */
c1 = isupper (*p1) ? tolower (*p1) : *p1;
c2 = isupper (*p2) ? tolower (*p2) : *p2;
if (c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
return c1 - c2;
#endif
}

694
elfutils/intl/localename.c Normal file
View File

@ -0,0 +1,694 @@
/* Determine the current selected locale.
Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <locale.h>
#if defined _WIN32 || defined __WIN32__
# undef WIN32 /* avoid warning on mingw32 */
# define WIN32
#endif
#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Mingw headers don't have latest language and sublanguage codes. */
# ifndef LANG_AFRIKAANS
# define LANG_AFRIKAANS 0x36
# endif
# ifndef LANG_ALBANIAN
# define LANG_ALBANIAN 0x1c
# endif
# ifndef LANG_ARABIC
# define LANG_ARABIC 0x01
# endif
# ifndef LANG_ARMENIAN
# define LANG_ARMENIAN 0x2b
# endif
# ifndef LANG_ASSAMESE
# define LANG_ASSAMESE 0x4d
# endif
# ifndef LANG_AZERI
# define LANG_AZERI 0x2c
# endif
# ifndef LANG_BASQUE
# define LANG_BASQUE 0x2d
# endif
# ifndef LANG_BELARUSIAN
# define LANG_BELARUSIAN 0x23
# endif
# ifndef LANG_BENGALI
# define LANG_BENGALI 0x45
# endif
# ifndef LANG_CATALAN
# define LANG_CATALAN 0x03
# endif
# ifndef LANG_ESTONIAN
# define LANG_ESTONIAN 0x25
# endif
# ifndef LANG_FAEROESE
# define LANG_FAEROESE 0x38
# endif
# ifndef LANG_FARSI
# define LANG_FARSI 0x29
# endif
# ifndef LANG_GEORGIAN
# define LANG_GEORGIAN 0x37
# endif
# ifndef LANG_GUJARATI
# define LANG_GUJARATI 0x47
# endif
# ifndef LANG_HEBREW
# define LANG_HEBREW 0x0d
# endif
# ifndef LANG_HINDI
# define LANG_HINDI 0x39
# endif
# ifndef LANG_INDONESIAN
# define LANG_INDONESIAN 0x21
# endif
# ifndef LANG_KANNADA
# define LANG_KANNADA 0x4b
# endif
# ifndef LANG_KASHMIRI
# define LANG_KASHMIRI 0x60
# endif
# ifndef LANG_KAZAK
# define LANG_KAZAK 0x3f
# endif
# ifndef LANG_KONKANI
# define LANG_KONKANI 0x57
# endif
# ifndef LANG_LATVIAN
# define LANG_LATVIAN 0x26
# endif
# ifndef LANG_LITHUANIAN
# define LANG_LITHUANIAN 0x27
# endif
# ifndef LANG_MACEDONIAN
# define LANG_MACEDONIAN 0x2f
# endif
# ifndef LANG_MALAY
# define LANG_MALAY 0x3e
# endif
# ifndef LANG_MALAYALAM
# define LANG_MALAYALAM 0x4c
# endif
# ifndef LANG_MANIPURI
# define LANG_MANIPURI 0x58
# endif
# ifndef LANG_MARATHI
# define LANG_MARATHI 0x4e
# endif
# ifndef LANG_NEPALI
# define LANG_NEPALI 0x61
# endif
# ifndef LANG_ORIYA
# define LANG_ORIYA 0x48
# endif
# ifndef LANG_PUNJABI
# define LANG_PUNJABI 0x46
# endif
# ifndef LANG_SANSKRIT
# define LANG_SANSKRIT 0x4f
# endif
# ifndef LANG_SERBIAN
# define LANG_SERBIAN 0x1a
# endif
# ifndef LANG_SINDHI
# define LANG_SINDHI 0x59
# endif
# ifndef LANG_SLOVAK
# define LANG_SLOVAK 0x1b
# endif
# ifndef LANG_SWAHILI
# define LANG_SWAHILI 0x41
# endif
# ifndef LANG_TAMIL
# define LANG_TAMIL 0x49
# endif
# ifndef LANG_TATAR
# define LANG_TATAR 0x44
# endif
# ifndef LANG_TELUGU
# define LANG_TELUGU 0x4a
# endif
# ifndef LANG_THAI
# define LANG_THAI 0x1e
# endif
# ifndef LANG_UKRAINIAN
# define LANG_UKRAINIAN 0x22
# endif
# ifndef LANG_URDU
# define LANG_URDU 0x20
# endif
# ifndef LANG_UZBEK
# define LANG_UZBEK 0x43
# endif
# ifndef LANG_VIETNAMESE
# define LANG_VIETNAMESE 0x2a
# endif
# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
# endif
# ifndef SUBLANG_ARABIC_IRAQ
# define SUBLANG_ARABIC_IRAQ 0x02
# endif
# ifndef SUBLANG_ARABIC_EGYPT
# define SUBLANG_ARABIC_EGYPT 0x03
# endif
# ifndef SUBLANG_ARABIC_LIBYA
# define SUBLANG_ARABIC_LIBYA 0x04
# endif
# ifndef SUBLANG_ARABIC_ALGERIA
# define SUBLANG_ARABIC_ALGERIA 0x05
# endif
# ifndef SUBLANG_ARABIC_MOROCCO
# define SUBLANG_ARABIC_MOROCCO 0x06
# endif
# ifndef SUBLANG_ARABIC_TUNISIA
# define SUBLANG_ARABIC_TUNISIA 0x07
# endif
# ifndef SUBLANG_ARABIC_OMAN
# define SUBLANG_ARABIC_OMAN 0x08
# endif
# ifndef SUBLANG_ARABIC_YEMEN
# define SUBLANG_ARABIC_YEMEN 0x09
# endif
# ifndef SUBLANG_ARABIC_SYRIA
# define SUBLANG_ARABIC_SYRIA 0x0a
# endif
# ifndef SUBLANG_ARABIC_JORDAN
# define SUBLANG_ARABIC_JORDAN 0x0b
# endif
# ifndef SUBLANG_ARABIC_LEBANON
# define SUBLANG_ARABIC_LEBANON 0x0c
# endif
# ifndef SUBLANG_ARABIC_KUWAIT
# define SUBLANG_ARABIC_KUWAIT 0x0d
# endif
# ifndef SUBLANG_ARABIC_UAE
# define SUBLANG_ARABIC_UAE 0x0e
# endif
# ifndef SUBLANG_ARABIC_BAHRAIN
# define SUBLANG_ARABIC_BAHRAIN 0x0f
# endif
# ifndef SUBLANG_ARABIC_QATAR
# define SUBLANG_ARABIC_QATAR 0x10
# endif
# ifndef SUBLANG_AZERI_LATIN
# define SUBLANG_AZERI_LATIN 0x01
# endif
# ifndef SUBLANG_AZERI_CYRILLIC
# define SUBLANG_AZERI_CYRILLIC 0x02
# endif
# ifndef SUBLANG_CHINESE_MACAU
# define SUBLANG_CHINESE_MACAU 0x05
# endif
# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
# endif
# ifndef SUBLANG_ENGLISH_JAMAICA
# define SUBLANG_ENGLISH_JAMAICA 0x08
# endif
# ifndef SUBLANG_ENGLISH_CARIBBEAN
# define SUBLANG_ENGLISH_CARIBBEAN 0x09
# endif
# ifndef SUBLANG_ENGLISH_BELIZE
# define SUBLANG_ENGLISH_BELIZE 0x0a
# endif
# ifndef SUBLANG_ENGLISH_TRINIDAD
# define SUBLANG_ENGLISH_TRINIDAD 0x0b
# endif
# ifndef SUBLANG_ENGLISH_ZIMBABWE
# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
# endif
# ifndef SUBLANG_ENGLISH_PHILIPPINES
# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
# endif
# ifndef SUBLANG_FRENCH_LUXEMBOURG
# define SUBLANG_FRENCH_LUXEMBOURG 0x05
# endif
# ifndef SUBLANG_FRENCH_MONACO
# define SUBLANG_FRENCH_MONACO 0x06
# endif
# ifndef SUBLANG_GERMAN_LUXEMBOURG
# define SUBLANG_GERMAN_LUXEMBOURG 0x04
# endif
# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
# endif
# ifndef SUBLANG_KASHMIRI_INDIA
# define SUBLANG_KASHMIRI_INDIA 0x02
# endif
# ifndef SUBLANG_MALAY_MALAYSIA
# define SUBLANG_MALAY_MALAYSIA 0x01
# endif
# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
# endif
# ifndef SUBLANG_NEPALI_INDIA
# define SUBLANG_NEPALI_INDIA 0x02
# endif
# ifndef SUBLANG_SERBIAN_LATIN
# define SUBLANG_SERBIAN_LATIN 0x02
# endif
# ifndef SUBLANG_SERBIAN_CYRILLIC
# define SUBLANG_SERBIAN_CYRILLIC 0x03
# endif
# ifndef SUBLANG_SPANISH_GUATEMALA
# define SUBLANG_SPANISH_GUATEMALA 0x04
# endif
# ifndef SUBLANG_SPANISH_COSTA_RICA
# define SUBLANG_SPANISH_COSTA_RICA 0x05
# endif
# ifndef SUBLANG_SPANISH_PANAMA
# define SUBLANG_SPANISH_PANAMA 0x06
# endif
# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
# endif
# ifndef SUBLANG_SPANISH_VENEZUELA
# define SUBLANG_SPANISH_VENEZUELA 0x08
# endif
# ifndef SUBLANG_SPANISH_COLOMBIA
# define SUBLANG_SPANISH_COLOMBIA 0x09
# endif
# ifndef SUBLANG_SPANISH_PERU
# define SUBLANG_SPANISH_PERU 0x0a
# endif
# ifndef SUBLANG_SPANISH_ARGENTINA
# define SUBLANG_SPANISH_ARGENTINA 0x0b
# endif
# ifndef SUBLANG_SPANISH_ECUADOR
# define SUBLANG_SPANISH_ECUADOR 0x0c
# endif
# ifndef SUBLANG_SPANISH_CHILE
# define SUBLANG_SPANISH_CHILE 0x0d
# endif
# ifndef SUBLANG_SPANISH_URUGUAY
# define SUBLANG_SPANISH_URUGUAY 0x0e
# endif
# ifndef SUBLANG_SPANISH_PARAGUAY
# define SUBLANG_SPANISH_PARAGUAY 0x0f
# endif
# ifndef SUBLANG_SPANISH_BOLIVIA
# define SUBLANG_SPANISH_BOLIVIA 0x10
# endif
# ifndef SUBLANG_SPANISH_EL_SALVADOR
# define SUBLANG_SPANISH_EL_SALVADOR 0x11
# endif
# ifndef SUBLANG_SPANISH_HONDURAS
# define SUBLANG_SPANISH_HONDURAS 0x12
# endif
# ifndef SUBLANG_SPANISH_NICARAGUA
# define SUBLANG_SPANISH_NICARAGUA 0x13
# endif
# ifndef SUBLANG_SPANISH_PUERTO_RICO
# define SUBLANG_SPANISH_PUERTO_RICO 0x14
# endif
# ifndef SUBLANG_SWEDISH_FINLAND
# define SUBLANG_SWEDISH_FINLAND 0x02
# endif
# ifndef SUBLANG_URDU_PAKISTAN
# define SUBLANG_URDU_PAKISTAN 0x01
# endif
# ifndef SUBLANG_URDU_INDIA
# define SUBLANG_URDU_INDIA 0x02
# endif
# ifndef SUBLANG_UZBEK_LATIN
# define SUBLANG_UZBEK_LATIN 0x01
# endif
# ifndef SUBLANG_UZBEK_CYRILLIC
# define SUBLANG_UZBEK_CYRILLIC 0x02
# endif
#endif
/* XPG3 defines the result of 'setlocale (category, NULL)' as:
"Directs 'setlocale()' to query 'category' and return the current
setting of 'local'."
However it does not specify the exact format. Neither do SUSV2 and
ISO C 99. So we can use this feature only on selected systems (e.g.
those using GNU C Library). */
#if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
# define HAVE_LOCALE_NULL
#endif
/* Determine the current locale's name, and canonicalize it into XPG syntax
language[_territory[.codeset]][@modifier]
The codeset part in the result is not reliable; the locale_charset()
should be used for codeset information instead.
The result must not be freed; it is statically allocated. */
const char *
_nl_locale_name (category, categoryname)
int category;
const char *categoryname;
{
const char *retval;
#ifndef WIN32
/* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
On some systems this can be done by the 'setlocale' function itself. */
# if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
retval = setlocale (category, NULL);
# else
/* Setting of LC_ALL overwrites all other. */
retval = getenv ("LC_ALL");
if (retval == NULL || retval[0] == '\0')
{
/* Next comes the name of the desired category. */
retval = getenv (categoryname);
if (retval == NULL || retval[0] == '\0')
{
/* Last possibility is the LANG environment variable. */
retval = getenv ("LANG");
if (retval == NULL || retval[0] == '\0')
/* We use C as the default domain. POSIX says this is
implementation defined. */
retval = "C";
}
}
# endif
return retval;
#else /* WIN32 */
/* Return an XPG style locale name language[_territory][@modifier].
Don't even bother determining the codeset; it's not useful in this
context, because message catalogs are not specific to a single
codeset. */
LCID lcid;
LANGID langid;
int primary, sub;
/* Let the user override the system settings through environment
variables, as on POSIX systems. */
retval = getenv ("LC_ALL");
if (retval != NULL && retval[0] != '\0')
return retval;
retval = getenv (categoryname);
if (retval != NULL && retval[0] != '\0')
return retval;
retval = getenv ("LANG");
if (retval != NULL && retval[0] != '\0')
return retval;
/* Use native Win32 API locale ID. */
lcid = GetThreadLocale ();
/* Strip off the sorting rules, keep only the language part. */
langid = LANGIDFROMLCID (lcid);
/* Split into language and territory part. */
primary = PRIMARYLANGID (langid);
sub = SUBLANGID (langid);
switch (primary)
{
case LANG_AFRIKAANS: return "af_ZA";
case LANG_ALBANIAN: return "sq_AL";
case LANG_ARABIC:
switch (sub)
{
case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
case SUBLANG_ARABIC_EGYPT: return "ar_EG";
case SUBLANG_ARABIC_LIBYA: return "ar_LY";
case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
case SUBLANG_ARABIC_OMAN: return "ar_OM";
case SUBLANG_ARABIC_YEMEN: return "ar_YE";
case SUBLANG_ARABIC_SYRIA: return "ar_SY";
case SUBLANG_ARABIC_JORDAN: return "ar_JO";
case SUBLANG_ARABIC_LEBANON: return "ar_LB";
case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
case SUBLANG_ARABIC_UAE: return "ar_AE";
case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
case SUBLANG_ARABIC_QATAR: return "ar_QA";
}
return "ar";
case LANG_ARMENIAN: return "hy_AM";
case LANG_ASSAMESE: return "as_IN";
case LANG_AZERI:
switch (sub)
{
/* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
}
return "az";
case LANG_BASQUE:
return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
case LANG_BELARUSIAN: return "be_BY";
case LANG_BENGALI: return "bn_IN";
case LANG_BULGARIAN: return "bg_BG";
case LANG_CATALAN: return "ca_ES";
case LANG_CHINESE:
switch (sub)
{
case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
case SUBLANG_CHINESE_MACAU: return "zh_MO";
}
return "zh";
case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN
* What used to be called Serbo-Croatian
* should really now be two separate
* languages because of political reasons.
* (Says tml, who knows nothing about Serbian
* or Croatian.)
* (I can feel those flames coming already.)
*/
switch (sub)
{
/* FIXME: How to distinguish Croatian and Latin Serbian locales? */
case SUBLANG_SERBIAN_LATIN: return "sr_YU";
case SUBLANG_SERBIAN_CYRILLIC: return "sr_YU@cyrillic";
default: return "hr_HR";
}
case LANG_CZECH: return "cs_CZ";
case LANG_DANISH: return "da_DK";
case LANG_DUTCH:
switch (sub)
{
case SUBLANG_DUTCH: return "nl_NL";
case SUBLANG_DUTCH_BELGIAN: return "nl_BE";
}
return "nl";
case LANG_ENGLISH:
switch (sub)
{
/* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
* English was the language spoken in England.
* Oh well.
*/
case SUBLANG_ENGLISH_US: return "en_US";
case SUBLANG_ENGLISH_UK: return "en_GB";
case SUBLANG_ENGLISH_AUS: return "en_AU";
case SUBLANG_ENGLISH_CAN: return "en_CA";
case SUBLANG_ENGLISH_NZ: return "en_NZ";
case SUBLANG_ENGLISH_EIRE: return "en_IE";
case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
}
return "en";
case LANG_ESTONIAN: return "et_EE";
case LANG_FAEROESE: return "fo_FO";
case LANG_FARSI: return "fa_IR";
case LANG_FINNISH: return "fi_FI";
case LANG_FRENCH:
switch (sub)
{
case SUBLANG_FRENCH: return "fr_FR";
case SUBLANG_FRENCH_BELGIAN: return "fr_BE";
case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
case SUBLANG_FRENCH_SWISS: return "fr_CH";
case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
case SUBLANG_FRENCH_MONACO: return "fr_MC";
}
return "fr";
case LANG_GEORGIAN: return "ka_GE";
case LANG_GERMAN:
switch (sub)
{
case SUBLANG_GERMAN: return "de_DE";
case SUBLANG_GERMAN_SWISS: return "de_CH";
case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
}
return "de";
case LANG_GREEK: return "el_GR";
case LANG_GUJARATI: return "gu_IN";
case LANG_HEBREW: return "he_IL";
case LANG_HINDI: return "hi_IN";
case LANG_HUNGARIAN: return "hu_HU";
case LANG_ICELANDIC: return "is_IS";
case LANG_INDONESIAN: return "id_ID";
case LANG_ITALIAN:
switch (sub)
{
case SUBLANG_ITALIAN: return "it_IT";
case SUBLANG_ITALIAN_SWISS: return "it_CH";
}
return "it";
case LANG_JAPANESE: return "ja_JP";
case LANG_KANNADA: return "kn_IN";
case LANG_KASHMIRI:
switch (sub)
{
case SUBLANG_DEFAULT: return "ks_PK";
case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
}
return "ks";
case LANG_KAZAK: return "kk_KZ";
case LANG_KONKANI:
/* FIXME: Adjust this when such locales appear on Unix. */
return "kok_IN";
case LANG_KOREAN: return "ko_KR";
case LANG_LATVIAN: return "lv_LV";
case LANG_LITHUANIAN: return "lt_LT";
case LANG_MACEDONIAN: return "mk_MK";
case LANG_MALAY:
switch (sub)
{
case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
}
return "ms";
case LANG_MALAYALAM: return "ml_IN";
case LANG_MANIPURI:
/* FIXME: Adjust this when such locales appear on Unix. */
return "mni_IN";
case LANG_MARATHI: return "mr_IN";
case LANG_NEPALI:
switch (sub)
{
case SUBLANG_DEFAULT: return "ne_NP";
case SUBLANG_NEPALI_INDIA: return "ne_IN";
}
return "ne";
case LANG_NORWEGIAN:
switch (sub)
{
case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
}
return "no";
case LANG_ORIYA: return "or_IN";
case LANG_POLISH: return "pl_PL";
case LANG_PORTUGUESE:
switch (sub)
{
case SUBLANG_PORTUGUESE: return "pt_PT";
/* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
}
return "pt";
case LANG_PUNJABI: return "pa_IN";
case LANG_ROMANIAN: return "ro_RO";
case LANG_RUSSIAN:
return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA". */
case LANG_SANSKRIT: return "sa_IN";
case LANG_SINDHI: return "sd";
case LANG_SLOVAK: return "sk_SK";
case LANG_SLOVENIAN: return "sl_SI";
case LANG_SORBIAN:
/* FIXME: Adjust this when such locales appear on Unix. */
return "wen_DE";
case LANG_SPANISH:
switch (sub)
{
case SUBLANG_SPANISH: return "es_ES";
case SUBLANG_SPANISH_MEXICAN: return "es_MX";
case SUBLANG_SPANISH_MODERN:
return "es_ES@modern"; /* not seen on Unix */
case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
case SUBLANG_SPANISH_PANAMA: return "es_PA";
case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
case SUBLANG_SPANISH_PERU: return "es_PE";
case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
case SUBLANG_SPANISH_ECUADOR: return "es_EC";
case SUBLANG_SPANISH_CHILE: return "es_CL";
case SUBLANG_SPANISH_URUGUAY: return "es_UY";
case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
case SUBLANG_SPANISH_HONDURAS: return "es_HN";
case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
}
return "es";
case LANG_SWAHILI: return "sw";
case LANG_SWEDISH:
switch (sub)
{
case SUBLANG_DEFAULT: return "sv_SE";
case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
}
return "sv";
case LANG_TAMIL:
return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
case LANG_TATAR: return "tt";
case LANG_TELUGU: return "te_IN";
case LANG_THAI: return "th_TH";
case LANG_TURKISH: return "tr_TR";
case LANG_UKRAINIAN: return "uk_UA";
case LANG_URDU:
switch (sub)
{
case SUBLANG_URDU_PAKISTAN: return "ur_PK";
case SUBLANG_URDU_INDIA: return "ur_IN";
}
return "ur";
case LANG_UZBEK:
switch (sub)
{
/* FIXME: Adjust this when Uzbek locales appear on Unix. */
case SUBLANG_UZBEK_LATIN: return "uz_UZ@latin";
case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
}
return "uz";
case LANG_VIETNAMESE: return "vi_VN";
default: return "C";
}
#endif
}

68
elfutils/intl/ngettext.c Normal file
View File

@ -0,0 +1,68 @@
/* Implementation of ngettext(3) function.
Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef _LIBC
# define __need_NULL
# include <stddef.h>
#else
# include <stdlib.h> /* Just for NULL. */
#endif
#include "gettextP.h"
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
#include <locale.h>
/* @@ end of prolog @@ */
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define NGETTEXT __ngettext
# define DCNGETTEXT __dcngettext
#else
# define NGETTEXT ngettext__
# define DCNGETTEXT dcngettext__
#endif
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
char *
NGETTEXT (msgid1, msgid2, n)
const char *msgid1;
const char *msgid2;
unsigned long int n;
{
return DCNGETTEXT (NULL, msgid1, msgid2, n, LC_MESSAGES);
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__ngettext, ngettext);
#endif

101
elfutils/intl/os2compat.c Normal file
View File

@ -0,0 +1,101 @@
/* OS/2 compatibility functions.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#define OS2_AWARE
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
/* A version of getenv() that works from DLLs */
extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
char *
_nl_getenv (const char *name)
{
unsigned char *value;
if (DosScanEnv (name, &value))
return NULL;
else
return value;
}
/* A fixed size buffer. */
#define LOCALEDIR_MAX 260
char _nl_default_dirname__[LOCALEDIR_MAX+1];
char *_os2_libdir = NULL;
char *_os2_localealiaspath = NULL;
char *_os2_localedir = NULL;
static __attribute__((constructor)) void
os2_initialize ()
{
char *root = getenv ("UNIXROOT");
char *gnulocaledir = getenv ("GNULOCALEDIR");
_os2_libdir = gnulocaledir;
if (!_os2_libdir)
{
if (root)
{
size_t sl = strlen (root);
_os2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
memcpy (_os2_libdir, root, sl);
memcpy (_os2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
}
else
_os2_libdir = LIBDIR;
}
_os2_localealiaspath = gnulocaledir;
if (!_os2_localealiaspath)
{
if (root)
{
size_t sl = strlen (root);
_os2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
memcpy (_os2_localealiaspath, root, sl);
memcpy (_os2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
}
else
_os2_localealiaspath = LOCALE_ALIAS_PATH;
}
_os2_localedir = gnulocaledir;
if (!_os2_localedir)
{
if (root)
{
size_t sl = strlen (root);
_os2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
memcpy (_os2_localedir, root, sl);
memcpy (_os2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
}
else
_os2_localedir = LOCALEDIR;
}
{
extern const char _nl_default_dirname__[];
if (strlen (_os2_localedir) <= LOCALEDIR_MAX)
strcpy (_nl_default_dirname__, _os2_localedir);
}
}

46
elfutils/intl/os2compat.h Normal file
View File

@ -0,0 +1,46 @@
/* OS/2 compatibility defines.
This file is intended to be included from config.h
Copyright (C) 2001-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* When included from os2compat.h we need all the original definitions */
#ifndef OS2_AWARE
#undef LIBDIR
#define LIBDIR _os2_libdir
extern char *_os2_libdir;
#undef LOCALEDIR
#define LOCALEDIR _os2_localedir
extern char *_os2_localedir;
#undef LOCALE_ALIAS_PATH
#define LOCALE_ALIAS_PATH _os2_localealiaspath
extern char *_os2_localealiaspath;
#endif
#undef HAVE_STRCASECMP
#define HAVE_STRCASECMP 1
#define strcasecmp stricmp
#define strncasecmp strnicmp
/* We have our own getenv() which works even if library is compiled as DLL */
#define getenv _nl_getenv
/* Older versions of gettext used -1 as the value of LC_MESSAGES */
#define LC_MESSAGES_COMPAT (-1)

24
elfutils/intl/osdep.c Normal file
View File

@ -0,0 +1,24 @@
/* OS dependent parts of libintl.
Copyright (C) 2001-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#if defined __EMX__
# include "os2compat.c"
#else
/* Avoid AIX compiler warning. */
typedef int dummy;
#endif

156
elfutils/intl/plural-exp.c Normal file
View File

@ -0,0 +1,156 @@
/* Expression parsing for plural form selection.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "plural-exp.h"
#if (defined __GNUC__ && !defined __APPLE_CC__) \
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
/* These structs are the constant expression for the germanic plural
form determination. It represents the expression "n != 1". */
static const struct expression plvar =
{
.nargs = 0,
.operation = var,
};
static const struct expression plone =
{
.nargs = 0,
.operation = num,
.val =
{
.num = 1
}
};
struct expression GERMANIC_PLURAL =
{
.nargs = 2,
.operation = not_equal,
.val =
{
.args =
{
[0] = (struct expression *) &plvar,
[1] = (struct expression *) &plone
}
}
};
# define INIT_GERMANIC_PLURAL()
#else
/* For compilers without support for ISO C 99 struct/union initializers:
Initialization at run-time. */
static struct expression plvar;
static struct expression plone;
struct expression GERMANIC_PLURAL;
static void
init_germanic_plural ()
{
if (plone.val.num == 0)
{
plvar.nargs = 0;
plvar.operation = var;
plone.nargs = 0;
plone.operation = num;
plone.val.num = 1;
GERMANIC_PLURAL.nargs = 2;
GERMANIC_PLURAL.operation = not_equal;
GERMANIC_PLURAL.val.args[0] = &plvar;
GERMANIC_PLURAL.val.args[1] = &plone;
}
}
# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
#endif
void
internal_function
EXTRACT_PLURAL_EXPRESSION (nullentry, pluralp, npluralsp)
const char *nullentry;
struct expression **pluralp;
unsigned long int *npluralsp;
{
if (nullentry != NULL)
{
const char *plural;
const char *nplurals;
plural = strstr (nullentry, "plural=");
nplurals = strstr (nullentry, "nplurals=");
if (plural == NULL || nplurals == NULL)
goto no_plural;
else
{
char *endp;
unsigned long int n;
struct parse_args args;
/* First get the number. */
nplurals += 9;
while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
++nplurals;
if (!(*nplurals >= '0' && *nplurals <= '9'))
goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
n = strtoul (nplurals, &endp, 10);
#else
for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
n = n * 10 + (*endp - '0');
#endif
if (nplurals == endp)
goto no_plural;
*npluralsp = n;
/* Due to the restrictions bison imposes onto the interface of the
scanner function we have to put the input string and the result
passed up from the parser into the same structure which address
is passed down to the parser. */
plural += 7;
args.cp = plural;
if (PLURAL_PARSE (&args) != 0)
goto no_plural;
*pluralp = args.res;
}
}
else
{
/* By default we are using the Germanic form: singular form only
for `one', the plural form otherwise. Yes, this is also what
English is using since English is a Germanic language. */
no_plural:
INIT_GERMANIC_PLURAL ();
*pluralp = &GERMANIC_PLURAL;
*npluralsp = 2;
}
}

122
elfutils/intl/plural-exp.h Normal file
View File

@ -0,0 +1,122 @@
/* Expression parsing and evaluation for plural form selection.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _PLURAL_EXP_H
#define _PLURAL_EXP_H
#ifndef PARAMS
# if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif
#endif
#ifndef internal_function
# define internal_function
#endif
/* This is the representation of the expressions to determine the
plural form. */
struct expression
{
int nargs; /* Number of arguments. */
enum operator
{
/* Without arguments: */
var, /* The variable "n". */
num, /* Decimal number. */
/* Unary operators: */
lnot, /* Logical NOT. */
/* Binary operators: */
mult, /* Multiplication. */
divide, /* Division. */
module, /* Modulo operation. */
plus, /* Addition. */
minus, /* Subtraction. */
less_than, /* Comparison. */
greater_than, /* Comparison. */
less_or_equal, /* Comparison. */
greater_or_equal, /* Comparison. */
equal, /* Comparison for equality. */
not_equal, /* Comparison for inequality. */
land, /* Logical AND. */
lor, /* Logical OR. */
/* Ternary operators: */
qmop /* Question mark operator. */
} operation;
union
{
unsigned long int num; /* Number value for `num'. */
struct expression *args[3]; /* Up to three arguments. */
} val;
};
/* This is the data structure to pass information to the parser and get
the result in a thread-safe way. */
struct parse_args
{
const char *cp;
struct expression *res;
};
/* Names for the libintl functions are a problem. This source code is used
1. in the GNU C Library library,
2. in the GNU libintl library,
3. in the GNU gettext tools.
The function names in each situation must be different, to allow for
binary incompatible changes in 'struct expression'. Furthermore,
1. in the GNU C Library library, the names have a __ prefix,
2.+3. in the GNU libintl library and in the GNU gettext tools, the names
must follow ANSI C and not start with __.
So we have to distinguish the three cases. */
#ifdef _LIBC
# define FREE_EXPRESSION __gettext_free_exp
# define PLURAL_PARSE __gettextparse
# define GERMANIC_PLURAL __gettext_germanic_plural
# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
#elif defined (IN_LIBINTL)
# define FREE_EXPRESSION gettext_free_exp__
# define PLURAL_PARSE gettextparse__
# define GERMANIC_PLURAL gettext_germanic_plural__
# define EXTRACT_PLURAL_EXPRESSION gettext_extract_plural__
#else
# define FREE_EXPRESSION free_plural_expression
# define PLURAL_PARSE parse_plural_expression
# define GERMANIC_PLURAL germanic_plural
# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
#endif
extern void FREE_EXPRESSION PARAMS ((struct expression *exp))
internal_function;
extern int PLURAL_PARSE PARAMS ((void *arg));
extern struct expression GERMANIC_PLURAL;
extern void EXTRACT_PLURAL_EXPRESSION PARAMS ((const char *nullentry,
struct expression **pluralp,
unsigned long int *npluralsp))
internal_function;
#if !defined (_LIBC) && !defined (IN_LIBINTL)
extern unsigned long int plural_eval PARAMS ((struct expression *pexp,
unsigned long int n));
#endif
#endif /* _PLURAL_EXP_H */

1518
elfutils/intl/plural.c Normal file

File diff suppressed because it is too large Load Diff

409
elfutils/intl/plural.y Normal file
View File

@ -0,0 +1,409 @@
%{
/* Expression parsing for plural form selection.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
/* The bison generated parser uses alloca. AIX 3 forces us to put this
declaration at the beginning of the file. The declaration in bison's
skeleton file comes too late. This must come before <config.h>
because <config.h> may include arbitrary system headers. */
#if defined _AIX && !defined __GNUC__
#pragma alloca
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stddef.h>
#include <stdlib.h>
#include "plural-exp.h"
/* The main function generated by the parser is called __gettextparse,
but we want it to be called PLURAL_PARSE. */
#ifndef _LIBC
# define __gettextparse PLURAL_PARSE
#endif
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
#define YYPARSE_PARAM arg
%}
%pure_parser
%expect 7
%union {
unsigned long int num;
enum operator op;
struct expression *exp;
}
%{
/* Prototypes for local functions. */
static struct expression *new_exp PARAMS ((int nargs, enum operator op,
struct expression * const *args));
static inline struct expression *new_exp_0 PARAMS ((enum operator op));
static inline struct expression *new_exp_1 PARAMS ((enum operator op,
struct expression *right));
static struct expression *new_exp_2 PARAMS ((enum operator op,
struct expression *left,
struct expression *right));
static inline struct expression *new_exp_3 PARAMS ((enum operator op,
struct expression *bexp,
struct expression *tbranch,
struct expression *fbranch));
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
static void yyerror PARAMS ((const char *str));
/* Allocation of expressions. */
static struct expression *
new_exp (nargs, op, args)
int nargs;
enum operator op;
struct expression * const *args;
{
int i;
struct expression *newp;
/* If any of the argument could not be malloc'ed, just return NULL. */
for (i = nargs - 1; i >= 0; i--)
if (args[i] == NULL)
goto fail;
/* Allocate a new expression. */
newp = (struct expression *) malloc (sizeof (*newp));
if (newp != NULL)
{
newp->nargs = nargs;
newp->operation = op;
for (i = nargs - 1; i >= 0; i--)
newp->val.args[i] = args[i];
return newp;
}
fail:
for (i = nargs - 1; i >= 0; i--)
FREE_EXPRESSION (args[i]);
return NULL;
}
static inline struct expression *
new_exp_0 (op)
enum operator op;
{
return new_exp (0, op, NULL);
}
static inline struct expression *
new_exp_1 (op, right)
enum operator op;
struct expression *right;
{
struct expression *args[1];
args[0] = right;
return new_exp (1, op, args);
}
static struct expression *
new_exp_2 (op, left, right)
enum operator op;
struct expression *left;
struct expression *right;
{
struct expression *args[2];
args[0] = left;
args[1] = right;
return new_exp (2, op, args);
}
static inline struct expression *
new_exp_3 (op, bexp, tbranch, fbranch)
enum operator op;
struct expression *bexp;
struct expression *tbranch;
struct expression *fbranch;
{
struct expression *args[3];
args[0] = bexp;
args[1] = tbranch;
args[2] = fbranch;
return new_exp (3, op, args);
}
%}
/* This declares that all operators have the same associativity and the
precedence order as in C. See [Harbison, Steele: C, A Reference Manual].
There is no unary minus and no bitwise operators.
Operators with the same syntactic behaviour have been merged into a single
token, to save space in the array generated by bison. */
%right '?' /* ? */
%left '|' /* || */
%left '&' /* && */
%left EQUOP2 /* == != */
%left CMPOP2 /* < > <= >= */
%left ADDOP2 /* + - */
%left MULOP2 /* * / % */
%right '!' /* ! */
%token <op> EQUOP2 CMPOP2 ADDOP2 MULOP2
%token <num> NUMBER
%type <exp> exp
%%
start: exp
{
if ($1 == NULL)
YYABORT;
((struct parse_args *) arg)->res = $1;
}
;
exp: exp '?' exp ':' exp
{
$$ = new_exp_3 (qmop, $1, $3, $5);
}
| exp '|' exp
{
$$ = new_exp_2 (lor, $1, $3);
}
| exp '&' exp
{
$$ = new_exp_2 (land, $1, $3);
}
| exp EQUOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| exp CMPOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| exp ADDOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| exp MULOP2 exp
{
$$ = new_exp_2 ($2, $1, $3);
}
| '!' exp
{
$$ = new_exp_1 (lnot, $2);
}
| 'n'
{
$$ = new_exp_0 (var);
}
| NUMBER
{
if (($$ = new_exp_0 (num)) != NULL)
$$->val.num = $1;
}
| '(' exp ')'
{
$$ = $2;
}
;
%%
void
internal_function
FREE_EXPRESSION (exp)
struct expression *exp;
{
if (exp == NULL)
return;
/* Handle the recursive case. */
switch (exp->nargs)
{
case 3:
FREE_EXPRESSION (exp->val.args[2]);
/* FALLTHROUGH */
case 2:
FREE_EXPRESSION (exp->val.args[1]);
/* FALLTHROUGH */
case 1:
FREE_EXPRESSION (exp->val.args[0]);
/* FALLTHROUGH */
default:
break;
}
free (exp);
}
static int
yylex (lval, pexp)
YYSTYPE *lval;
const char **pexp;
{
const char *exp = *pexp;
int result;
while (1)
{
if (exp[0] == '\0')
{
*pexp = exp;
return YYEOF;
}
if (exp[0] != ' ' && exp[0] != '\t')
break;
++exp;
}
result = *exp++;
switch (result)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
{
unsigned long int n = result - '0';
while (exp[0] >= '0' && exp[0] <= '9')
{
n *= 10;
n += exp[0] - '0';
++exp;
}
lval->num = n;
result = NUMBER;
}
break;
case '=':
if (exp[0] == '=')
{
++exp;
lval->op = equal;
result = EQUOP2;
}
else
result = YYERRCODE;
break;
case '!':
if (exp[0] == '=')
{
++exp;
lval->op = not_equal;
result = EQUOP2;
}
break;
case '&':
case '|':
if (exp[0] == result)
++exp;
else
result = YYERRCODE;
break;
case '<':
if (exp[0] == '=')
{
++exp;
lval->op = less_or_equal;
}
else
lval->op = less_than;
result = CMPOP2;
break;
case '>':
if (exp[0] == '=')
{
++exp;
lval->op = greater_or_equal;
}
else
lval->op = greater_than;
result = CMPOP2;
break;
case '*':
lval->op = mult;
result = MULOP2;
break;
case '/':
lval->op = divide;
result = MULOP2;
break;
case '%':
lval->op = module;
result = MULOP2;
break;
case '+':
lval->op = plus;
result = ADDOP2;
break;
case '-':
lval->op = minus;
result = ADDOP2;
break;
case 'n':
case '?':
case ':':
case '(':
case ')':
/* Nothing, just return the character. */
break;
case ';':
case '\n':
case '\0':
/* Be safe and let the user call this function again. */
--exp;
result = YYEOF;
break;
default:
result = YYERRCODE;
#if YYDEBUG != 0
--exp;
#endif
break;
}
*pexp = exp;
return result;
}
static void
yyerror (str)
const char *str;
{
/* Do nothing. We don't print error messages here. */
}

31
elfutils/intl/ref-add.sin Normal file
View File

@ -0,0 +1,31 @@
# Add this package to a list of references stored in a text file.
#
# Copyright (C) 2000 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# Written by Bruno Haible <haible@clisp.cons.org>.
#
/^# Packages using this file: / {
s/# Packages using this file://
ta
:a
s/ @PACKAGE@ / @PACKAGE@ /
tb
s/ $/ @PACKAGE@ /
:b
s/^/# Packages using this file:/
}

26
elfutils/intl/ref-del.sin Normal file
View File

@ -0,0 +1,26 @@
# Remove this package from a list of references stored in a text file.
#
# Copyright (C) 2000 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; either version 2, 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# Written by Bruno Haible <haible@clisp.cons.org>.
#
/^# Packages using this file: / {
s/# Packages using this file://
s/ @PACKAGE@ / /
s/^/# Packages using this file:/
}

142
elfutils/intl/textdomain.c Normal file
View File

@ -0,0 +1,142 @@
/* Implementation of the textdomain(3) function.
Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#ifdef _LIBC
# include <libintl.h>
#else
# include "libgnuintl.h"
#endif
#include "gettextP.h"
#ifdef _LIBC
/* We have to handle multi-threaded applications. */
# include <bits/libc-lock.h>
#else
/* Provide dummy implementation if this is outside glibc. */
# define __libc_rwlock_define(CLASS, NAME)
# define __libc_rwlock_wrlock(NAME)
# define __libc_rwlock_unlock(NAME)
#endif
/* The internal variables in the standalone libintl.a must have different
names than the internal variables in GNU libc, otherwise programs
using libintl.a cannot be linked statically. */
#if !defined _LIBC
# define _nl_default_default_domain _nl_default_default_domain__
# define _nl_current_default_domain _nl_current_default_domain__
#endif
/* @@ end of prolog @@ */
/* Name of the default text domain. */
extern const char _nl_default_default_domain[];
/* Default text domain in which entries for gettext(3) are to be found. */
extern const char *_nl_current_default_domain;
/* Names for the libintl functions are a problem. They must not clash
with existing names and they should follow ANSI C. But this source
code is also used in GNU C Library where the names have a __
prefix. So we have to make a difference here. */
#ifdef _LIBC
# define TEXTDOMAIN __textdomain
# ifndef strdup
# define strdup(str) __strdup (str)
# endif
#else
# define TEXTDOMAIN textdomain__
#endif
/* Lock variable to protect the global data in the gettext implementation. */
__libc_rwlock_define (extern, _nl_state_lock)
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
char *
TEXTDOMAIN (domainname)
const char *domainname;
{
char *new_domain;
char *old_domain;
/* A NULL pointer requests the current setting. */
if (domainname == NULL)
return (char *) _nl_current_default_domain;
__libc_rwlock_wrlock (_nl_state_lock);
old_domain = (char *) _nl_current_default_domain;
/* If domain name is the null string set to default domain "messages". */
if (domainname[0] == '\0'
|| strcmp (domainname, _nl_default_default_domain) == 0)
{
_nl_current_default_domain = _nl_default_default_domain;
new_domain = (char *) _nl_current_default_domain;
}
else if (strcmp (domainname, old_domain) == 0)
/* This can happen and people will use it to signal that some
environment variable changed. */
new_domain = old_domain;
else
{
/* If the following malloc fails `_nl_current_default_domain'
will be NULL. This value will be returned and so signals we
are out of core. */
#if defined _LIBC || defined HAVE_STRDUP
new_domain = strdup (domainname);
#else
size_t len = strlen (domainname) + 1;
new_domain = (char *) malloc (len);
if (new_domain != NULL)
memcpy (new_domain, domainname, len);
#endif
if (new_domain != NULL)
_nl_current_default_domain = new_domain;
}
/* We use this possibility to signal a change of the loaded catalogs
since this is most likely the case and there is no other easy we
to do it. Do it only when the call was successful. */
if (new_domain != NULL)
{
++_nl_msg_cat_cntr;
if (old_domain != new_domain && old_domain != _nl_default_default_domain)
free (old_domain);
}
__libc_rwlock_unlock (_nl_state_lock);
return new_domain;
}
#ifdef _LIBC
/* Alias for function name in GNU C Library. */
weak_alias (__textdomain, textdomain);
#endif

12
elfutils/lib/Makefile.am Normal file
View File

@ -0,0 +1,12 @@
## Process this file with automake to create Makefile.in
AUTOMAKE_OPTIONS = 1.4 gnits
noinst_LTLIBRARIES = libbu.la
INCLUDES = -I$(srcdir)/../libelf -I..
libbu_la_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c
noinst_HEADERS = fixedsizehash.h system.h \
dynamicsizehash.h dynamicsizehash.c

362
elfutils/lib/Makefile.in Normal file
View File

@ -0,0 +1,362 @@
# Makefile.in generated by automake 1.6a from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@
AMTAR = @AMTAR@
AS = @AS@
AWK = @AWK@
BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIB = @HAVE_LIB@
INCLTDL = @INCLTDL@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTOBJEXT = @INSTOBJEXT@
INTLBISON = @INTLBISON@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIB = @LIB@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LOCALEDIR = @LOCALEDIR@
LTLIB = @LTLIB@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
MKINSTALLDIRS = @MKINSTALLDIRS@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
POSUB = @POSUB@
RANLIB = @RANLIB@
STRIP = @STRIP@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
am__include = @am__include@
am__quote = @am__quote@
install_sh = @install_sh@
AUTOMAKE_OPTIONS = 1.4 gnits
noinst_LTLIBRARIES = libbu.la
INCLUDES = -I$(srcdir)/../libelf -I..
libbu_la_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c
noinst_HEADERS = fixedsizehash.h system.h \
dynamicsizehash.h dynamicsizehash.c
subdir = lib
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libbu_la_LDFLAGS =
libbu_la_LIBADD =
am_libbu_la_OBJECTS = xstrdup.lo xstrndup.lo xmalloc.lo next_prime.lo
libbu_la_OBJECTS = $(am_libbu_la_OBJECTS)
DEFS = @DEFS@
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/next_prime.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/xmalloc.Plo ./$(DEPDIR)/xstrdup.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/xstrndup.Plo
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
DIST_SOURCES = $(libbu_la_SOURCES)
HEADERS = $(noinst_HEADERS)
DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in
SOURCES = $(libbu_la_SOURCES)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnits lib/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
libbu.la: $(libbu_la_OBJECTS) $(libbu_la_DEPENDENCIES)
$(LINK) $(libbu_la_LDFLAGS) $(libbu_la_OBJECTS) $(libbu_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT) core *.core
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/next_prime.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrdup.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrndup.Plo@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.c.o:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$<
.c.obj:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `cygpath -w $<`
.c.lo:
@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
CCDEPMODE = @CCDEPMODE@
uninstall-info-am:
ETAGS = etags
ETAGSFLAGS =
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
uninstall-am: uninstall-info-am
.PHONY: GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES distclean \
distclean-compile distclean-depend distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am info \
info-am install install-am install-data install-data-am \
install-exec install-exec-am install-info install-info-am \
install-man install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool tags uninstall uninstall-am \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,309 @@
/* Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <assert.h>
#include <stdlib.h>
#include <system.h>
/* Before including this file the following macros must be defined:
NAME name of the hash table structure.
TYPE data type of the hash table entries
COMPARE comparison function taking two pointers to TYPE objects
The following macros if present select features:
ITERATE iterating over the table entries is possible
REVERSE iterate in reverse order of insert
*/
static size_t
lookup (htab, hval, val)
NAME *htab;
unsigned long int hval;
TYPE val;
{
/* First hash function: simply take the modul but prevent zero. */
size_t idx = 1 + hval % htab->size;
if (htab->table[idx].hashval != 0)
{
unsigned long int hash;
if (htab->table[idx].hashval == hval
&& COMPARE (htab->table[idx].data, val) == 0)
return idx;
/* Second hash function as suggested in [Knuth]. */
hash = 1 + hval % (htab->size - 2);
do
{
if (idx <= hash)
idx = htab->size + idx - hash;
else
idx -= hash;
/* If entry is found use it. */
if (htab->table[idx].hashval == hval
&& COMPARE (htab->table[idx].data, val) == 0)
return idx;
}
while (htab->table[idx].hashval);
}
return idx;
}
static void
insert_entry_2 (NAME *htab, unsigned long int hval, size_t idx, TYPE data)
{
#ifdef ITERATE
if (htab->table[idx].hashval == 0)
{
# ifdef REVERSE
htab->table[idx].next = htab->first;
htab->first = &htab->table[idx];
# else
/* Add the new value to the list. */
if (htab->first == NULL)
htab->first = htab->table[idx].next = &htab->table[idx];
else
{
htab->table[idx].next = htab->first->next;
htab->first = htab->first->next = &htab->table[idx];
}
# endif
}
#endif
htab->table[idx].hashval = hval;
htab->table[idx].data = data;
++htab->filled;
if (100 * htab->filled > 90 * htab->size)
{
/* Table is filled more than 90%. Resize the table. */
#ifdef ITERATE
__typeof__ (htab->first) first;
# ifndef REVERSE
__typeof__ (htab->first) runp;
# endif
#else
unsigned long int old_size = htab->size;
#endif
#define _TABLE(name) \
name##_ent *table = htab->table
#define TABLE(name) _TABLE (name)
TABLE(NAME);
htab->size = next_prime (htab->size * 2);
htab->filled = 0;
#ifdef ITERATE
first = htab->first;
htab->first = NULL;
#endif
htab->table = xcalloc ((1 + htab->size), sizeof (htab->table[0]));
if (htab->table == NULL)
{
/* We cannot enlarge the table. Live with what we got. This
might lead to an infinite loop at some point, though. */
htab->table = table;
return;
}
/* Add the old entries to the new table. When iteration is
supported we maintain the order. */
#ifdef ITERATE
# ifdef REVERSE
while (first != NULL)
{
insert_entry_2 (htab, first->hashval,
lookup (htab, first->hashval, first->data),
first->data);
first = first->next;
}
# else
assert (first != NULL);
runp = first = first->next;
do
insert_entry_2 (htab, runp->hashval,
lookup (htab, runp->hashval, runp->data), runp->data);
while ((runp = runp->next) != first);
# endif
#else
for (idx = 1; idx <= old_size; ++idx)
if (table[idx].hashval != 0)
insert_entry_2 (htab, table[idx].hashval,
lookup (htab, table[idx].hashval, table[idx].data),
table[idx].data);
#endif
free (table);
}
}
int
#define INIT(name) _INIT (name)
#define _INIT(name) \
name##_init
INIT(NAME) (htab, init_size)
NAME *htab;
unsigned long int init_size;
{
/* We need the size to be a prime. */
init_size = next_prime (init_size);
/* Initialize the data structure. */
htab->size = init_size;
htab->filled = 0;
#ifdef ITERATE
htab->first = NULL;
#endif
htab->table = (void *) xcalloc ((init_size + 1), sizeof (htab->table[0]));
if (htab->table == NULL)
return -1;
return 0;
}
int
#define FREE(name) _FREE (name)
#define _FREE(name) \
name##_free
FREE(NAME) (htab)
NAME *htab;
{
free (htab->table);
return 0;
}
int
#define INSERT(name) _INSERT (name)
#define _INSERT(name) \
name##_insert
INSERT(NAME) (htab, hval, data)
NAME *htab;
unsigned long int hval;
TYPE data;
{
size_t idx;
/* Make the hash value nonzero. */
hval = hval ?: 1;
idx = lookup (htab, hval, data);
if (htab->table[idx].hashval != 0)
/* We don't want to overwrite the old value. */
return -1;
/* An empty bucket has been found. */
insert_entry_2 (htab, hval, idx, data);
return 0;
}
#ifdef OVERWRITE
int
#define INSERT(name) _INSERT (name)
#define _INSERT(name) \
name##_overwrite
INSERT(NAME) (htab, hval, data)
NAME *htab;
unsigned long int hval;
TYPE data;
{
size_t idx;
/* Make the hash value nonzero. */
hval = hval ?: 1;
idx = lookup (htab, hval, data);
/* The correct bucket has been found. */
insert_entry_2 (htab, hval, idx, data);
return 0;
}
#endif
TYPE
#define FIND(name) _FIND (name)
#define _FIND(name) \
name##_find
FIND(NAME) (htab, hval, val)
NAME *htab;
unsigned long int hval;
TYPE val;
{
size_t idx;
/* Make the hash value nonzero. */
hval = hval ?: 1;
idx = lookup (htab, hval, val);
if (htab->table[idx].hashval == 0)
return NULL;
return htab->table[idx].data;
}
#ifdef ITERATE
# define ITERATEFCT(name) _ITERATEFCT (name)
# define _ITERATEFCT(name) \
name##_iterate
TYPE
ITERATEFCT(NAME) (htab, ptr)
NAME *htab;
void **ptr;
{
# define TYPENAME(name) _TYPENAME (name)
# define _TYPENAME(name) \
name##_ent
# ifdef REVERSE
if (*ptr == NULL)
*ptr = htab->first;
else
*ptr = ((TYPENAME(NAME) *) *ptr)->next;
if (*ptr == NULL)
return NULL;
# else
if (*ptr == NULL)
{
if (htab->first == NULL)
return NULL;
*ptr = htab->first->next;
}
else
{
if (*ptr == htab->first)
return NULL;
*ptr = ((TYPENAME(NAME) *) *ptr)->next;
}
# endif
return ((TYPENAME(NAME) *) *ptr)->data;
}
#endif

View File

@ -0,0 +1,110 @@
/* Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stddef.h>
/* Before including this file the following macros must be defined:
NAME name of the hash table structure.
TYPE data type of the hash table entries
The following macros if present select features:
ITERATE iterating over the table entries is possible
*/
/* Optionally include an entry pointing to the first used entry. */
#ifdef ITERATE
# define FIRST(name) name##_ent *first;
# define NEXT(name) struct name##_ent *next;
#else
# define FIRST(name)
# define NEXT(name)
#endif
/* Defined separately. */
extern size_t next_prime (size_t seed);
/* Table entry type. */
#define _DYNHASHENTTYPE(name) \
typedef struct name##_ent \
{ \
unsigned long int hashval; \
TYPE data; \
NEXT (name) \
} name##_ent
#define DYNHASHENTTYPE(name) _DYNHASHENTTYPE (name)
DYNHASHENTTYPE (NAME);
/* Type of the dynamic hash table data structure. */
#define _DYNHASHTYPE(name) \
typedef struct \
{ \
unsigned long int size; \
unsigned long int filled; \
name##_ent *table; \
FIRST (name) \
} name
#define DYNHASHTYPE(name) _DYNHASHTYPE (name)
DYNHASHTYPE (NAME);
#define _FUNCTIONS(name) \
/* Initialize the hash table. */ \
extern int name##_init (name *htab, unsigned long int init_size); \
\
/* Free resources allocated for hash table. */ \
extern int name##_free (name *htab); \
\
/* Insert new entry. */ \
extern int name##_insert (name *htab, unsigned long int hval, TYPE data); \
\
/* Insert new entry, possibly overwrite old entry. */ \
extern int name##_overwrite (name *htab, unsigned long int hval, TYPE data); \
\
/* Find entry in hash table. */ \
extern TYPE name##_find (name *htab, unsigned long int hval, TYPE val);
#define FUNCTIONS(name) _FUNCTIONS (name)
FUNCTIONS (NAME)
#ifdef ITERATE
# define _XFUNCTIONS(name) \
/* Get next element in table. */ \
extern TYPE name##_iterate (name *htab, void **ptr);
# define XFUNCTIONS(name) _XFUNCTIONS (name)
XFUNCTIONS (NAME)
#endif
#ifndef NO_UNDEF
# undef DYNHASHENTTYPE
# undef DYNHASHTYPE
# undef FUNCTIONS
# undef _FUNCTIONS
# undef XFUNCTIONS
# undef _XFUNCTIONS
# undef NAME
# undef TYPE
# undef ITERATE
# undef COMPARE
# undef FIRST
# undef NEXT
#endif

View File

@ -0,0 +1,251 @@
/* Fixed size hash table with internal linking.
Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/param.h>
#include <system.h>
#define CONCAT(t1,t2) __CONCAT (t1,t2)
/* Before including this file the following macros must be defined:
TYPE data type of the hash table entries
HASHFCT name of the hashing function to use
HASHTYPE type used for the hashing value
COMPARE comparison function taking two pointers to TYPE objects
CLASS can be defined to `static' to avoid exporting the functions
PREFIX prefix to be used for function and data type names
STORE_POINTER if defined the table stores a pointer and not an element
of type TYPE
INSERT_HASH if defined alternate insert function which takes a hash
value is defined
NO_FINI_FCT if defined the fini function is not defined
*/
/* Defined separately. */
extern size_t next_prime (size_t seed);
/* Set default values. */
#ifndef HASHTYPE
# define HASHTYPE size_t
#endif
#ifndef CLASS
# define CLASS
#endif
#ifndef PREFIX
# define PREFIX
#endif
/* The data structure. */
struct CONCAT(PREFIX,fshash)
{
size_t nslots;
struct CONCAT(PREFIX,fshashent)
{
HASHTYPE hval;
#ifdef STORE_POINTER
# define ENTRYP(el) (el).entry
TYPE *entry;
#else
# define ENTRYP(el) &(el).entry
TYPE entry;
#endif
} table[0];
};
/* Constructor for the hashing table. */
CLASS struct CONCAT(PREFIX,fshash) *
CONCAT(PREFIX,fshash_init) (size_t nelems)
{
struct CONCAT(PREFIX,fshash) *result;
/* We choose a size for the hashing table 150% over the number of
entries. This will guarantee short medium search lengths. */
const size_t max_size_t = ~((size_t) 0);
if (nelems >= (max_size_t / 3) * 2)
{
errno = EINVAL;
return NULL;
}
/* Adjust the size to be used for the hashing table. */
nelems = next_prime (MAX ((nelems * 3) / 2, 10));
/* Allocate the data structure for the result. */
result = (struct CONCAT(PREFIX,fshash) *)
xcalloc (sizeof (struct CONCAT(PREFIX,fshash))
+ (nelems + 1) * sizeof (struct CONCAT(PREFIX,fshashent)), 1);
if (result == NULL)
return NULL;
result->nslots = nelems;
return result;
}
#ifndef NO_FINI_FCT
CLASS void
CONCAT(PREFIX,fshash_fini) (struct CONCAT(PREFIX,fshash) *htab)
{
free (htab);
}
#endif
static struct CONCAT(PREFIX,fshashent) *
CONCAT(PREFIX,fshash_lookup) (struct CONCAT(PREFIX,fshash) *htab,
HASHTYPE hval, TYPE *data)
{
size_t idx = 1 + hval % htab->nslots;
if (htab->table[idx].hval != 0)
{
HASHTYPE hash;
/* See whether this is the same entry. */
if (htab->table[idx].hval == hval
&& COMPARE (data, ENTRYP (htab->table[idx])) == 0)
return &htab->table[idx];
/* Second hash function as suggested in [Knuth]. */
hash = 1 + hval % (htab->nslots - 2);
do
{
if (idx <= hash)
idx = htab->nslots + idx - hash;
else
idx -= hash;
if (htab->table[idx].hval == hval
&& COMPARE (data, ENTRYP(htab->table[idx])) == 0)
return &htab->table[idx];
}
while (htab->table[idx].hval != 0);
}
return &htab->table[idx];
}
CLASS int
__attribute__ ((unused))
CONCAT(PREFIX,fshash_insert) (struct CONCAT(PREFIX,fshash) *htab,
const char *str, size_t len, TYPE *data)
{
HASHTYPE hval = HASHFCT (str, len ?: strlen (str));
struct CONCAT(PREFIX,fshashent) *slot;
slot = CONCAT(PREFIX,fshash_lookup) (htab, hval, data);
if (slot->hval != 0)
/* We don't want to overwrite the old value. */
return -1;
slot->hval = hval;
#ifdef STORE_POINTER
slot->entry = data;
#else
slot->entry = *data;
#endif
return 0;
}
#ifdef INSERT_HASH
CLASS int
__attribute__ ((unused))
CONCAT(PREFIX,fshash_insert_hash) (struct CONCAT(PREFIX,fshash) *htab,
HASHTYPE hval, TYPE *data)
{
struct CONCAT(PREFIX,fshashent) *slot;
slot = CONCAT(PREFIX,fshash_lookup) (htab, hval, data);
if (slot->hval != 0)
/* We don't want to overwrite the old value. */
return -1;
slot->hval = hval;
#ifdef STORE_POINTER
slot->entry = data;
#else
slot->entry = *data;
#endif
return 0;
}
#endif
CLASS int
__attribute__ ((unused))
CONCAT(PREFIX,fshash_overwrite) (struct CONCAT(PREFIX,fshash) *htab,
const char *str, size_t len, TYPE *data)
{
HASHTYPE hval = HASHFCT (str, len ?: strlen (str));
struct CONCAT(PREFIX,fshashent) *slot;
slot = CONCAT(PREFIX,fshash_lookup) (htab, hval, data);
slot->hval = hval;
#ifdef STORE_POINTER
slot->entry = data;
#else
slot->entry = *data;
#endif
return 0;
}
const CLASS TYPE *
CONCAT(PREFIX,fshash_find) (const struct CONCAT(PREFIX,fshash) *htab,
const char *str, size_t len, TYPE *data)
{
HASHTYPE hval = HASHFCT (str, len ?: strlen (str));
struct CONCAT(PREFIX,fshashent) *slot;
slot = CONCAT(PREFIX,fshash_lookup) ((struct CONCAT(PREFIX,fshash) *) htab,
hval, data);
if (slot->hval == 0)
/* Not found. */
return NULL;
return ENTRYP(*slot);
}
/* Unset the macros we expect. */
#undef TYPE
#undef HASHFCT
#undef HASHTYPE
#undef COMPARE
#undef CLASS
#undef PREFIX
#undef INSERT_HASH
#undef STORE_POINTER
#undef NO_FINI_FCT

54
elfutils/lib/next_prime.c Normal file
View File

@ -0,0 +1,54 @@
/* Determine prime number.
Copyright (C) 2000, 2002 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stddef.h>
/* Test whether CANDIDATE is a prime. */
static int
is_prime (size_t candidate)
{
/* No even number and none less than 10 will be passed here. */
size_t divn = 3;
size_t sq = divn * divn;
while (sq < candidate && candidate % divn != 0)
{
size_t old_sq = sq;
++divn;
sq += 4 * divn;
if (sq < old_sq)
return 1;
++divn;
}
return candidate % divn != 0;
}
/* We need primes for the table size. */
size_t
next_prime (size_t seed)
{
/* Make it definitely odd. */
seed |= 1;
while (!is_prime (seed))
seed += 2;
return seed;
}

21
elfutils/lib/system.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef BU_SYSTEM_H
#define BU_SYSTEM_H 1
#include <stddef.h>
extern void *xmalloc (size_t) __attribute__ ((__malloc__));
extern void *xcalloc (size_t, size_t) __attribute__ ((__malloc__));
extern void *xrealloc (void *, size_t) __attribute__ ((__malloc__));
extern char *xstrdup (const char *) __attribute__ ((__malloc__));
extern char *xstrndup (const char *, size_t) __attribute__ ((__malloc__));
/* A special gettext function we use if the strings are too short. */
#define sgettext(Str) \
({ const char *__res = strrchr (gettext (Str), '|'); \
__res ? __res + 1 : Str; })
#define gettext_noop(Str) Str
#endif /* system.h */

117
elfutils/lib/xmalloc.c Normal file
View File

@ -0,0 +1,117 @@
/* xmalloc.c -- malloc with out of memory checking
Copyright (C) 1990,91,92,93,94,95,96,97 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#if __STDC__
#define VOID void
#else
#define VOID char
#endif
#include <sys/types.h>
#if STDC_HEADERS || _LIBC
#include <stdlib.h>
static VOID *fixup_null_alloc __P ((size_t n));
VOID *xmalloc __P ((size_t n));
VOID *xcalloc __P ((size_t n, size_t s));
VOID *xrealloc __P ((VOID *p, size_t n));
#else
VOID *calloc ();
VOID *malloc ();
VOID *realloc ();
void free ();
#endif
#include <libintl.h>
#include "error.h"
#ifndef _
# define _(str) gettext (str)
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 4
#endif
/* Exit value when the requested amount of memory is not available.
The caller may set it to some other value. */
int xmalloc_exit_failure = EXIT_FAILURE;
static VOID *
fixup_null_alloc (n)
size_t n;
{
VOID *p;
p = 0;
if (n == 0)
p = malloc ((size_t) 1);
if (p == 0)
error (xmalloc_exit_failure, 0, _("memory exhausted"));
return p;
}
/* Allocate N bytes of memory dynamically, with error checking. */
VOID *
xmalloc (n)
size_t n;
{
VOID *p;
p = malloc (n);
if (p == 0)
p = fixup_null_alloc (n);
return p;
}
/* Allocate memory for N elements of S bytes, with error checking. */
VOID *
xcalloc (n, s)
size_t n, s;
{
VOID *p;
p = calloc (n, s);
if (p == 0)
p = fixup_null_alloc (n);
return p;
}
/* Change the size of an allocated block of memory P to N bytes,
with error checking.
If P is NULL, run xmalloc. */
VOID *
xrealloc (p, n)
VOID *p;
size_t n;
{
if (p == 0)
return xmalloc (n);
p = realloc (p, n);
if (p == 0)
p = fixup_null_alloc (n);
return p;
}

39
elfutils/lib/xstrdup.c Normal file
View File

@ -0,0 +1,39 @@
/* xstrdup.c -- copy a string with out of memory checking
Copyright (C) 1990, 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC
# include <string.h>
#else
# include <strings.h>
#endif
void *xmalloc __P ((size_t n));
char *xstrdup __P ((char *string));
/* Return a newly allocated copy of STRING. */
char *
xstrdup (string)
char *string;
{
return strcpy (xmalloc (strlen (string) + 1), string);
}

46
elfutils/lib/xstrndup.c Normal file
View File

@ -0,0 +1,46 @@
/* Copy a string with out of memory checking
Copyright (C) 1990, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC
# include <string.h>
#else
# include <strings.h>
#endif
void *xmalloc __P ((size_t n));
char *xstrndup __P ((char *string, size_t n));
/* Return a newly allocated copy of STRING. */
char *
xstrndup (string, n)
char *string;
size_t n;
{
char *res;
size_t len = strnlen (string, n);
if (len > n)
len = n;
res = memcpy (xmalloc (len + 1), string, len);
res[len] = '\0';
return res;
}

View File

@ -0,0 +1,246 @@
# Makefile for program source directory in GNU NLS utilities package.
# Copyright (C) 1995, 1996, 1997, 2000 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
PACKAGE = libasm
VERSION = @VERSION@
SHELL = /bin/sh
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = $(prefix)/@DATADIRNAME@
localedir = $(datadir)/locale
gnulocaledir = $(prefix)/share/locale
gettextsrcdir = $(prefix)/share/gettext/po
subdir = po
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = @MKINSTALLDIRS@
CC = @CC@
GENCAT = @GENCAT@
GMSGFMT = PATH=../src:$$PATH @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = PATH=../src:$$PATH @XGETTEXT@
MSGMERGE = PATH=../src:$$PATH msgmerge
DEFS = @DEFS@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
INCLUDES = -I.. -I$(top_srcdir)/intl
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
SOURCES = cat-id-tbl.c
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = Makefile.in.in POTFILES.in $(PACKAGE).pot \
stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES)
POTFILES = \
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
INSTOBJEXT = @INSTOBJEXT@
.SUFFIXES:
.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
.c.o:
$(COMPILE) $<
.po.pox:
$(MAKE) $(PACKAGE).pot
$(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
.po.mo:
$(MSGFMT) -o $@ $<
.po.gmo:
file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
&& rm -f $$file && $(GMSGFMT) -o $$file $<
.po.cat:
sed -f ../intl/po2msg.sed < $< > $*.msg \
&& rm -f $@ && $(GENCAT) $@ $*.msg
all: all-@USE_NLS@
all-yes: cat-id-tbl.c $(CATALOGS)
all-no:
$(srcdir)/$(PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(top_srcdir) \
--add-comments --keyword=_ --keyword=N_ \
--files-from=$(srcdir)/POTFILES.in \
&& test ! -f $(PACKAGE).po \
|| ( rm -f $(srcdir)/$(PACKAGE).pot \
&& mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot )
$(srcdir)/cat-id-tbl.c: stamp-cat-id; @:
$(srcdir)/stamp-cat-id: $(PACKAGE).pot
rm -f cat-id-tbl.tmp
sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
| sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
if cmp -s cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; then \
rm cat-id-tbl.tmp; \
else \
echo cat-id-tbl.c changed; \
rm -f $(srcdir)/cat-id-tbl.c; \
mv cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; \
fi
cd $(srcdir) && rm -f stamp-cat-id && echo timestamp > stamp-cat-id
install: install-exec install-data
install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
if test -x "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
fi
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
case "$$cat" in \
*.gmo) destdir=$(DESTDIR)$(gnulocaledir);; \
*) destdir=$(DESTDIR)$(localedir);; \
esac; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
dir=$$destdir/$$lang/LC_MESSAGES; \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $$dir; \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
fi; \
if test -r $$cat; then \
$(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \
else \
$(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
echo "installing $(srcdir)/$$cat as" \
"$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
fi; \
if test -r $$cat.m; then \
$(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
else \
if test -r $(srcdir)/$$cat.m ; then \
$(INSTALL_DATA) $(srcdir)/$$cat.m \
$$dir/$(PACKAGE)$(INSTOBJEXT).m; \
echo "installing $(srcdir)/$$cat as" \
"$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
else \
true; \
fi; \
fi; \
done
if test "$(PACKAGE)" = "gettext"; then \
if test -x "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
fi; \
$(INSTALL_DATA) $(srcdir)/Makefile.in.in \
$(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
else \
: ; \
fi
# Define this as empty until I found a useful application.
installcheck:
uninstall:
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \
done
check: all
cat-id-tbl.o: ../intl/libgettext.h
dvi info tags TAGS ID:
mostlyclean:
rm -f core core.* *.pox $(PACKAGE).po *.old.po cat-id-tbl.tmp
rm -fr *.o
clean: mostlyclean
distclean: clean
rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f $(GMOFILES)
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
dist distdir: update-po $(DISTFILES)
dists="$(DISTFILES)"; \
for file in $$dists; do \
cp -p $(srcdir)/$$file $(distdir); \
done
update-po: Makefile
$(MAKE) $(PACKAGE).pot
PATH=`pwd`/../src:$$PATH; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
mv $$lang.po $$lang.old.po; \
echo "$$lang:"; \
if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \
rm -f $$lang.old.po; \
else \
echo "msgmerge for $$cat failed!"; \
rm -f $$lang.po; \
mv $$lang.old.po $$lang.po; \
fi; \
done
POTFILES: POTFILES.in
( if test 'x$(srcdir)' != 'x.'; then \
posrcprefix='$(top_srcdir)/'; \
else \
posrcprefix="../"; \
fi; \
rm -f $@-t $@ \
&& (sed -e '/^#/d' -e '/^[ ]*$$/d' \
-e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
| sed -e '$$s/\\$$//') > $@-t \
&& chmod a-w $@-t \
&& mv $@-t $@ )
Makefile: Makefile.in.in ../config.status POTFILES
cd .. \
&& CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
$(SHELL) ./config.status
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,5 @@
libasm/asm_begin.c
libasm/asm_abort.c
libasm/asm_end.c
libasm/asm_error.c
libasm/asm_getelf.c

View File

View File

@ -0,0 +1,68 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2002-06-28 12:01-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: libasm/asm_end.c:96 libasm/asm_end.c:134 libasm/asm_end.c:150
#: libasm/asm_end.c:271
#, c-format
msgid "cannot create section for output file: %s"
msgstr ""
#: libasm/asm_end.c:212
#, c-format
msgid "cannot create extended section index table: %s"
msgstr ""
#: libasm/asm_end.c:308
#, c-format
msgid "cannot create section group for output file: %s"
msgstr ""
#: libasm/asm_error.c:111
msgid "no error"
msgstr ""
#: libasm/asm_error.c:112
msgid "out of memory"
msgstr ""
#: libasm/asm_error.c:113
msgid "cannot create output file"
msgstr ""
#: libasm/asm_error.c:114
msgid "invalid parameter"
msgstr ""
#: libasm/asm_error.c:115
msgid "cannot change mode of output file"
msgstr ""
#: libasm/asm_error.c:116
msgid "cannot rename output file"
msgstr ""
#: libasm/asm_error.c:117
msgid "duplicate symbol"
msgstr ""
#: libasm/asm_error.c:118
msgid "invalid section type for operation"
msgstr ""
#: libasm/asm_error.c:152
msgid "Unknown error"
msgstr ""

View File

@ -0,0 +1 @@
timestamp

View File

@ -0,0 +1,40 @@
## Process this file with automake to create Makefile.in
AUTOMAKE_OPTIONS = 1.4 gnits
DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
AM_CFLAGS = -Wall -Werror
INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
-I$(top_srcdir)/lib
GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
LINT = splint
lib_LTLIBRARIES = libasm.la
include_HEADERS = libasm.h
libasm_la_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
asm_getelf.c asm_newscn.c asm_newscn_ingrp.c \
asm_newsubscn.c asm_newsym.c asm_newcomsym.c \
asm_newabssym.c \
asm_newscngrp.c asm_scngrp_newsignature.c \
asm_fill.c asm_align.c asm_addstrz.c \
asm_addint8.c asm_adduint8.c \
asm_addint16.c asm_adduint16.c \
asm_addint32.c asm_adduint32.c \
asm_addint64.c asm_adduint64.c \
symbolhash.c
libasm_la_LIBADD = ../libebl/libebl.la ../libelf/libelf.la
libasm_la_LDFLAGS = -export-symbols $(srcdir)/libasm.sym
libasm_la_DEPENDENCIES = $(libasm_la_LIBADD) libasm.sym
noinst_HEADERS = libasmP.h symbolhash.h
EXTRA_DIST = libasm.sym
.PSEUDO: lint
lint:
$(LINT) $(DEFS) $(INCLUDES) $(GCC_INCLUDE) -f $(top_srcdir)/splint.rc \
$(addprefix $(srcdir)/,$(libelf_la_SOURCES))

475
elfutils/libasm/Makefile.in Normal file
View File

@ -0,0 +1,475 @@
# Makefile.in generated by automake 1.6a from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@
AMTAR = @AMTAR@
AS = @AS@
AWK = @AWK@
BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
ECHO = @ECHO@
GENCAT = @GENCAT@
GLIBC21 = @GLIBC21@
GMSGFMT = @GMSGFMT@
HAVE_LIB = @HAVE_LIB@
INCLTDL = @INCLTDL@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTOBJEXT = @INSTOBJEXT@
INTLBISON = @INTLBISON@
INTLLIBS = @INTLLIBS@
INTLOBJS = @INTLOBJS@
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIB = @LIB@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LOCALEDIR = @LOCALEDIR@
LTLIB = @LTLIB@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
MKINSTALLDIRS = @MKINSTALLDIRS@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
POSUB = @POSUB@
RANLIB = @RANLIB@
STRIP = @STRIP@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
YACC = @YACC@
am__include = @am__include@
am__quote = @am__quote@
install_sh = @install_sh@
AUTOMAKE_OPTIONS = 1.4 gnits
DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
AM_CFLAGS = -Wall -Werror
INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
-I$(top_srcdir)/lib
GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
LINT = splint
lib_LTLIBRARIES = libasm.la
include_HEADERS = libasm.h
libasm_la_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
asm_getelf.c asm_newscn.c asm_newscn_ingrp.c \
asm_newsubscn.c asm_newsym.c asm_newcomsym.c \
asm_newabssym.c \
asm_newscngrp.c asm_scngrp_newsignature.c \
asm_fill.c asm_align.c asm_addstrz.c \
asm_addint8.c asm_adduint8.c \
asm_addint16.c asm_adduint16.c \
asm_addint32.c asm_adduint32.c \
asm_addint64.c asm_adduint64.c \
symbolhash.c
libasm_la_LIBADD = ../libebl/libebl.la ../libelf/libelf.la
libasm_la_LDFLAGS = -export-symbols $(srcdir)/libasm.sym
libasm_la_DEPENDENCIES = $(libasm_la_LIBADD) libasm.sym
noinst_HEADERS = libasmP.h symbolhash.h
EXTRA_DIST = libasm.sym
subdir = libasm
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
am_libasm_la_OBJECTS = asm_begin.lo asm_abort.lo asm_end.lo asm_error.lo \
asm_getelf.lo asm_newscn.lo asm_newscn_ingrp.lo \
asm_newsubscn.lo asm_newsym.lo asm_newcomsym.lo \
asm_newabssym.lo asm_newscngrp.lo asm_scngrp_newsignature.lo \
asm_fill.lo asm_align.lo asm_addstrz.lo asm_addint8.lo \
asm_adduint8.lo asm_addint16.lo asm_adduint16.lo \
asm_addint32.lo asm_adduint32.lo asm_addint64.lo \
asm_adduint64.lo symbolhash.lo
libasm_la_OBJECTS = $(am_libasm_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/asm_abort.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_addint16.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_addint32.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_addint64.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_addint8.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_addstrz.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_adduint16.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_adduint32.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_adduint64.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_adduint8.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_align.Plo ./$(DEPDIR)/asm_begin.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_end.Plo ./$(DEPDIR)/asm_error.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_fill.Plo ./$(DEPDIR)/asm_getelf.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newabssym.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newcomsym.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newscn.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newscn_ingrp.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newscngrp.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newsubscn.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_newsym.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/asm_scngrp_newsignature.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/symbolhash.Plo
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
DIST_SOURCES = $(libasm_la_SOURCES)
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = $(include_HEADERS) $(noinst_HEADERS) Makefile.am \
Makefile.in
SOURCES = $(libasm_la_SOURCES)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnits libasm/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
libLTLIBRARIES_INSTALL = $(INSTALL)
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
libasm.la: $(libasm_la_OBJECTS) $(libasm_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libasm_la_LDFLAGS) $(libasm_la_OBJECTS) $(libasm_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT) core *.core
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_abort.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_addint16.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_addint32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_addint64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_addint8.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_addstrz.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_adduint16.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_adduint32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_adduint64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_adduint8.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_align.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_begin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_end.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_error.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_fill.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_getelf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newabssym.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newcomsym.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newscn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newscn_ingrp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newscngrp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newsubscn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_newsym.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_scngrp_newsignature.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbolhash.Plo@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.c.o:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$<
.c.obj:
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(COMPILE) -c `cygpath -w $<`
.c.lo:
@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
$(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
CCDEPMODE = @CCDEPMODE@
uninstall-info-am:
includeHEADERS_INSTALL = $(INSTALL_HEADER)
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \
$(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(include_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f $(DESTDIR)$(includedir)/$$f"; \
rm -f $(DESTDIR)$(includedir)/$$f; \
done
ETAGS = etags
ETAGSFLAGS =
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pR $$d/$$file $(distdir)$$dir \
|| exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
info: info-am
info-am:
install-data-am: install-includeHEADERS
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
uninstall-am: uninstall-includeHEADERS uninstall-info-am \
uninstall-libLTLIBRARIES
.PHONY: GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool distclean distclean-compile \
distclean-depend distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-includeHEADERS install-info \
install-info-am install-libLTLIBRARIES install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
tags uninstall uninstall-am uninstall-includeHEADERS \
uninstall-info-am uninstall-libLTLIBRARIES
.PSEUDO: lint
lint:
$(LINT) $(DEFS) $(INCLUDES) $(GCC_INCLUDE) -f $(top_srcdir)/splint.rc \
$(addprefix $(srcdir)/,$(libelf_la_SOURCES))
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,48 @@
/* Abort operations on the assembler context, free all resources.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <unistd.h>
#include <libasmP.h>
#include <libelf.h>
int
asm_abort (ctx)
AsmCtx_t *ctx;
{
if (ctx == NULL)
/* Something went wrong earlier. */
return -1;
if (likely (! ctx->textp))
/* First free the ELF file. We don't care about the result. */
(void) elf_end (ctx->out.elf);
/* Now close the temporary file and remove it. */
(void) unlink (ctx->tmp_fname);
/* Free the resources. */
__libasm_finictx (ctx);
return 0;
}

View File

@ -0,0 +1,20 @@
/* Add integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SIZE 16
#include "asm_addint8.c"

View File

@ -0,0 +1,20 @@
/* Add integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SIZE 32
#include "asm_addint8.c"

View File

@ -0,0 +1,20 @@
/* Add integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SIZE 64
#include "asm_addint8.c"

View File

@ -0,0 +1,105 @@
/* Add integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <byteswap.h>
#include <endian.h>
#include <inttypes.h>
#include <string.h>
#include <libasmP.h>
#ifndef SIZE
# define SIZE 8
#endif
#define FCT(size) _FCT(size)
#define _FCT(size) asm_addint##size
#define TYPE(size) _TYPE(size)
#define _TYPE(size) int##size##_t
#define BSWAP(size) _BSWAP(size)
#define _BSWAP(size) bswap_##size
int
FCT(SIZE) (asmscn, num)
AsmScn_t *asmscn;
TYPE(SIZE) num;
{
if (asmscn == NULL)
return -1;
if (asmscn->type == SHT_NOBITS && unlikely (num != 0))
{
__libasm_seterrno (ASM_E_TYPE);
return -1;
}
if (unlikely (asmscn->ctx->textp))
{
// XXX Needs to use backend specified pseudo-ops
if (SIZE == 8)
printf ("\t.byte\t%" PRId8 "\n", (int8_t) num);
else if (SIZE == 16)
printf ("\t.value\t%" PRId16 "\n", (int16_t) num);
else if (SIZE == 32)
printf ("\t.long\t%" PRId32 "\n", (int32_t) num);
else
{
// XXX This is not necessary for 64-bit machines
bool is_leb = (elf_getident (asmscn->ctx->out.elf, NULL)[EI_DATA]
== ELFDATA2LSB);
printf ("\t.long\t%" PRId32 "\n\t.long\t%" PRId32 "\n",
(int32_t) (is_leb
? num % 0x100000000ll : num / 0x100000000ll),
(int32_t) (is_leb
? num / 0x100000000ll : num % 0x100000000ll));
}
}
else
{
#if SIZE > 8
bool is_leb = (elf_getident (asmscn->ctx->out.elf, NULL)[EI_DATA]
== ELFDATA2LSB);
#endif
TYPE(SIZE) var = num;
/* Make sure we have enough room. */
__libasm_ensure_section_space (asmscn, SIZE / 8);
#if SIZE > 8
if ((BYTE_ORDER == LITTLE_ENDIAN && !is_leb)
|| (BYTE_ORDER == BIG_ENDIAN && is_leb))
var = BSWAP(SIZE) (var);
#endif
/* Copy the variable value. */
memcpy (&asmscn->content->data[asmscn->content->len], &var, SIZE / 8);
/* Adjust the pointer in the data buffer. */
asmscn->content->len += SIZE / 8;
/* Increment the offset in the (sub)section. */
asmscn->offset += SIZE / 8;
}
return 0;
}
INTDEF(FCT(SIZE))

View File

@ -0,0 +1,115 @@
/* Add string to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <libasmP.h>
/* Add zero terminated string STR of size LEN to (sub)section ASMSCN. */
int
asm_addstrz (asmscn, str, len)
AsmScn_t *asmscn;
const char *str;
size_t len;
{
if (asmscn == NULL)
return -1;
if (unlikely (asmscn->type == SHT_NOBITS))
{
if (len == 0)
{
if (str[0] != '\0')
{
__libasm_seterrno (ASM_E_TYPE);
return -1;
}
}
else
{
size_t cnt;
for (cnt = 0; cnt < len; ++cnt)
if (str[cnt] != '\0')
{
__libasm_seterrno (ASM_E_TYPE);
return -1;
}
}
}
if (len == 0)
len = strlen (str) + 1;
if (unlikely (asmscn->ctx->textp))
{
bool nextline = true;
do
{
if (nextline)
{
fputs ("\t.string\t\"", asmscn->ctx->out.file);
nextline = false;
}
if (*str == '\0')
fputs ("\\000", asmscn->ctx->out.file);
else if (! isascii (*str))
fprintf (asmscn->ctx->out.file, "\\%03o",
(unsigned int) *((unsigned char *)str));
else if (*str == '\\')
fputs ("\\\\", asmscn->ctx->out.file);
else if (*str == '\n')
{
fputs ("\\n\"", asmscn->ctx->out.file);
nextline = true;
}
else
fputc (*str, asmscn->ctx->out.file);
++str;
}
while (--len > 0 && (len > 1 || *str != '\0'));
if (! nextline)
fputs ("\"\n", asmscn->ctx->out.file);
}
else
{
/* Make sure there is enough room. */
__libasm_ensure_section_space (asmscn, len);
/* Copy the string. */
memcpy (&asmscn->content->data[asmscn->content->len], str, len);
/* Adjust the pointer in the data buffer. */
asmscn->content->len += len;
/* Increment the offset in the (sub)section. */
asmscn->offset += len;
}
return 0;
}

View File

@ -0,0 +1,20 @@
/* Add unsigned integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SIZE 16
#include "asm_adduint8.c"

View File

@ -0,0 +1,20 @@
/* Add unsigned integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SIZE 32
#include "asm_adduint8.c"

View File

@ -0,0 +1,20 @@
/* Add unsigned integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SIZE 64
#include "asm_adduint8.c"

View File

@ -0,0 +1,44 @@
/* Add unsigned integer to a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libasmP.h>
#ifndef SIZE
# define SIZE 8
#endif
#define UFCT(size) _UFCT(size)
#define _UFCT(size) asm_adduint##size
#define FCT(size) _FCT(size)
#define _FCT(size) asm_addint##size
#define UTYPE(size) _UTYPE(size)
#define _UTYPE(size) uint##size##_t
#define TYPE(size) _TYPE(size)
#define _TYPE(size) int##size##_t
int
UFCT(SIZE) (asmscn, num)
AsmScn_t *asmscn;
UTYPE(SIZE) num;
{
return INTUSE(FCT(SIZE)) (asmscn, (TYPE(SIZE)) num);
}

138
elfutils/libasm/asm_align.c Normal file
View File

@ -0,0 +1,138 @@
/* Align section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/param.h>
#include <libasmP.h>
#include <system.h>
int
asm_align (asmscn, value)
AsmScn_t *asmscn;
GElf_Word value;
{
if (asmscn == NULL)
/* An earlier error. */
return -1;
/* The alignment value must be a power of two. */
if (unlikely (! powerof2 (value)))
{
__libasm_seterrno (ASM_E_INVALID);
return -1;
}
rwlock_wrlock (asmscn->ctx->lock);
/* Fillbytes necessary? */
if ((asmscn->offset & (value - 1)) != 0)
{
/* Add fillbytes. */
size_t cnt;
size_t byteptr;
cnt = value - (asmscn->offset & (value - 1));
/* Ensure there is enough room to add the fill bytes. */
__libasm_ensure_section_space (asmscn, cnt);
/* Fill in the bytes. We align the pattern according to the
current offset. */
byteptr = asmscn->offset % asmscn->pattern->len;
/* Update the total size. */
asmscn->offset += cnt;
do
{
asmscn->content->data[asmscn->content->len++]
= asmscn->pattern->bytes[byteptr++];
if (byteptr == asmscn->pattern->len)
byteptr = 0;
}
while (--cnt > 0);
}
/* Remember the maximum alignment for this subsection. */
if (asmscn->max_align < value)
{
asmscn->max_align = value;
/* Update the parent as well (if it exists). */
if (asmscn->subsection_id != 0)
{
rwlock_wrlock (asmscn->data.up->ctx->lock);
if (asmscn->data.up->max_align < value)
asmscn->data.up->max_align = value;
rwlock_unlock (asmscn->data.up->ctx->lock);
}
}
rwlock_unlock (asmscn->ctx->lock);
return 0;
}
/* Ensure there are at least LEN bytes available in the output buffer
for ASMSCN. */
void
__libasm_ensure_section_space (asmscn, len)
AsmScn_t *asmscn;
size_t len;
{
/* The blocks with the section content are kept in a circular
single-linked list. */
size_t size;
if (asmscn->content == NULL)
{
/* This is the first block. */
size = MAX (2 * len, 960);
asmscn->content = (struct AsmData *) xmalloc (sizeof (struct AsmData)
+ size);
asmscn->content->next = asmscn->content;
}
else
{
struct AsmData *newp;
if (asmscn->content->maxlen - asmscn->content->len >= len)
/* Nothing to do, there is enough space. */
return;
size = MAX (2 *len, MIN (32768, 2 * asmscn->offset));
newp = (struct AsmData *) xmalloc (sizeof (struct AsmData) + size);
newp->next = asmscn->content->next;
asmscn->content = asmscn->content->next = newp;
}
asmscn->content->len = 0;
asmscn->content->maxlen = size;
}

151
elfutils/libasm/asm_begin.c Normal file
View File

@ -0,0 +1,151 @@
/* Create descriptor for assembling.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <gelf.h>
#include "libasmP.h"
#include <system.h>
static AsmCtx_t *
prepare_text_output (AsmCtx_t *result)
{
return result;
}
static AsmCtx_t *
prepare_binary_output (AsmCtx_t *result, int machine, int klass, int data)
{
GElf_Ehdr *ehdr;
GElf_Ehdr ehdr_mem;
/* Create the ELF descriptor for the file. */
result->out.elf = elf_begin (result->fd, ELF_C_WRITE_MMAP, NULL);
if (result->out.elf == NULL)
{
err_libelf:
unlink (result->tmp_fname);
close (result->fd);
free (result);
__libasm_seterrno (ASM_E_LIBELF);
return NULL;
}
/* Create the ELF header for the output file. */
if (gelf_newehdr (result->out.elf, klass) == 0)
goto err_libelf;
ehdr = gelf_getehdr (result->out.elf, &ehdr_mem);
/* If this failed we are in trouble. */
assert (ehdr != NULL);
/* We create an object file. */
ehdr->e_type = ET_REL;
/* Set the ELF version. */
ehdr->e_version = EV_CURRENT;
/* Use the machine value the user provided. */
ehdr->e_machine = machine;
/* Same for the class and endianness. */
ehdr->e_ident[EI_CLASS] = klass;
ehdr->e_ident[EI_DATA] = data;
memcpy (&ehdr->e_ident[EI_MAG0], ELFMAG, SELFMAG);
/* Write the ELF header information back. */
(void) gelf_update_ehdr (result->out.elf, ehdr);
/* No section so far. */
result->section_list = NULL;
/* Initialize the hash table. */
asm_symbol_tab_init (&result->symbol_tab, 67);
/* And the string tables. */
result->section_strtab = ebl_strtabinit (true);
result->symbol_strtab = ebl_strtabinit (true);
/* We have no section groups so far. */
result->groups = NULL;
result->ngroups = 0;
return result;
}
AsmCtx_t *
asm_begin (fname, textp, machine, klass, data)
const char *fname;
bool textp;
int machine;
int klass;
int data;
{
size_t fname_len = strlen (fname);
AsmCtx_t *result;
/* First order of business: find the appropriate backend. If it
does not exist we don't have to look further. */
// XXX
/* Create the file descriptor. We do not generate the output file
right away. Instead we create a temporary file in the same
directory which, if everything goes alright, will replace a
possibly existing file with the given name. */
result = (AsmCtx_t *) xmalloc (sizeof (AsmCtx_t) + 2 * fname_len + 9);
/* Initialize the lock. */
rwlock_init (result->lock);
/* Create the name of the temporary file. */
result->fname = stpcpy (mempcpy (result->tmp_fname, fname, fname_len),
".XXXXXX") + 1;
memcpy (result->fname, fname, fname_len + 1);
/* Create the temporary file. */
result->fd = mkstemp (result->tmp_fname);
if (result->fd == -1)
{
int save_errno = errno;
free (result);
__libasm_seterrno (ASM_E_CANNOT_CREATE);
errno = save_errno;
return NULL;
}
/* Initialize the counter for temporary symbols. */
result->tempsym_count = 0;
/* Now we differentiate between textual and binary output. */
result->textp = textp;
if (textp)
result = prepare_text_output (result);
else
result = prepare_binary_output (result, machine, klass, data);
return result;
}

523
elfutils/libasm/asm_end.c Normal file
View File

@ -0,0 +1,523 @@
/* Finalize operations on the assembler context, free all resources.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include <error.h>
#include <libintl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <libasmP.h>
#include <libelf.h>
#include <system.h>
static int
text_end (AsmCtx_t *ctx)
{
// XXX Does anything have to be done?
return 0;
}
static int
binary_end (AsmCtx_t *ctx)
{
void *symtab = NULL;
struct Ebl_Strent *symscn_strent = NULL;
struct Ebl_Strent *strscn_strent = NULL;
struct Ebl_Strent *xndxscn_strent = NULL;
Elf_Scn *shstrscn;
struct Ebl_Strent *shstrscn_strent;
size_t shstrscnndx;
size_t symscnndx = 0;
size_t strscnndx = 0;
size_t xndxscnndx = 0;
Elf_Data *data;
GElf_Shdr shdr_mem;
GElf_Shdr *shdr;
GElf_Ehdr ehdr_mem;
GElf_Ehdr *ehdr;
AsmScn_t *asmscn;
/* Iterate over the created sections and compute the offsets of the
various subsections and fill in the content. */
for (asmscn = ctx->section_list; asmscn != NULL; asmscn = asmscn->allnext)
{
#if 0
Elf_Scn *scn = elf_getscn (ctx->out.elf, asmscn->data.main.scnndx);
#else
Elf_Scn *scn = asmscn->data.main.scn;
#endif
off_t offset = 0;
AsmScn_t *asmsubscn = asmscn;
do
{
struct AsmData *content = asmsubscn->content;
bool first = true;
offset = ((offset + asmsubscn->max_align - 1)
& ~(asmsubscn->max_align - 1));
/* Update the offset for this subsection. This field now
stores the offset of the first by in this subsection. */
asmsubscn->offset = offset;
/* Note that the content list is circular. */
if (content != NULL)
do
{
Elf_Data *newdata = elf_newdata (scn);
if (newdata == NULL)
error (EXIT_FAILURE, 0,
_("cannot create section for output file: %s"),
elf_errmsg (-1));
newdata->d_buf = content->data;
newdata->d_type = ELF_T_BYTE;
newdata->d_size = content->len;
newdata->d_off = offset;
newdata->d_align = first ? asmsubscn->max_align : 1;
offset += content->len;
}
while ((content = content->next) != asmsubscn->content);
}
while ((asmsubscn = asmsubscn->subnext) != NULL);
}
/* Create the symbol table if necessary. */
if (ctx->nsymbol_tab > 0)
{
Elf_Scn *symscn;
Elf_Scn *strscn;
AsmSym_t *sym;
int ptr_local;
int ptr_nonlocal;
GElf_Sym syment;
uint32_t *xshndx = NULL;
void *runp;
/* Create the symbol table and string table section names. */
symscn_strent = ebl_strtabadd (ctx->section_strtab, ".symtab", 8);
strscn_strent = ebl_strtabadd (ctx->section_strtab, ".strtab", 8);
/* Create the symbol string table section. */
strscn = elf_newscn (ctx->out.elf);
data = elf_newdata (strscn);
shdr = gelf_getshdr (strscn, &shdr_mem);
if (data == NULL || shdr == NULL)
error (EXIT_FAILURE, 0, _("cannot create section for output file: %s"),
elf_errmsg (-1));
strscnndx = elf_ndxscn (strscn);
ebl_strtabfinalize (ctx->symbol_strtab, data);
shdr->sh_type = SHT_STRTAB;
assert (shdr->sh_entsize == 0);
(void) gelf_update_shdr (strscn, shdr);
/* Create the symbol table section. */
symscn = elf_newscn (ctx->out.elf);
data = elf_newdata (symscn);
shdr = gelf_getshdr (symscn, &shdr_mem);
if (data == NULL || shdr == NULL)
error (EXIT_FAILURE, 0, _("cannot create section for output file: %s"),
elf_errmsg (-1));
symscnndx = elf_ndxscn (symscn);
/* We know how many symbols there will be in the symbol table. */
data->d_size = gelf_fsize (ctx->out.elf, ELF_T_SYM,
ctx->nsymbol_tab + 1, EV_CURRENT);
symtab = xmalloc (data->d_size);
data->d_buf = symtab;
data->d_type = ELF_T_SYM;
data->d_off = 0;
/* Clear the first entry. */
memset (&syment, '\0', sizeof (syment));
(void) gelf_update_sym (data, 0, &syment);
/* Iterate over the symbol table. */
runp = NULL;
ptr_local = 1; /* Start with index 1; zero remains unused. */
ptr_nonlocal = ctx->nsymbol_tab;
while ((sym = asm_symbol_tab_iterate (&ctx->symbol_tab, &runp)) != NULL)
if (asm_emit_symbol_p (ebl_string (sym->strent)))
{
int ptr;
Elf32_Word ndx;
Elf_Scn *scn;
assert (ptr_local <= ptr_nonlocal);
syment.st_name = ebl_strtaboffset (sym->strent);
syment.st_info = GELF_ST_INFO (sym->binding, sym->type);
syment.st_other = 0;
syment.st_value = sym->scn->offset + sym->offset;
syment.st_size = sym->size;
/* Add local symbols at the beginning, the other from the end. */
ptr = sym->binding == STB_LOCAL ? ptr_local++ : ptr_nonlocal--;
/* Determine the section index. We have to handle the
overflow correctly. */
scn = (sym->scn->subsection_id == 0
? sym->scn->data.main.scn
: sym->scn->data.up->data.main.scn);
if (unlikely (scn == ASM_ABS_SCN))
ndx = SHN_ABS;
else if (unlikely (scn == ASM_COM_SCN))
ndx = SHN_COMMON;
else if (unlikely ((ndx = elf_ndxscn (scn)) >= SHN_LORESERVE))
{
if (unlikely (xshndx == NULL))
{
/* The extended section index section does not yet
exist. */
Elf_Scn *xndxscn;
size_t symscnndx = elf_ndxscn (symscn);
Elf_Data *xndxdata;
xndxscn = elf_newscn (ctx->out.elf);
xndxdata = elf_newdata (xndxscn);
shdr = gelf_getshdr (xndxscn, &shdr_mem);
if (xndxdata == NULL || shdr == NULL)
error (EXIT_FAILURE, 0, _("\
cannot create extended section index table: %s"),
elf_errmsg (-1));
xndxscnndx = elf_ndxscn (xndxscn);
shdr->sh_type = SHT_SYMTAB_SHNDX;
shdr->sh_entsize = sizeof (Elf32_Word);
shdr->sh_link = symscnndx;
(void) gelf_update_shdr (xndxscn, shdr);
xndxscn_strent = ebl_strtabadd (ctx->section_strtab,
".symtab_shndx", 14);
/* Note that using 'elf32_fsize' instead of
'gelf_fsize' here is correct. */
xndxdata->d_size = elf32_fsize (ELF_T_WORD,
ctx->nsymbol_tab + 1,
EV_CURRENT);
xshndx = xndxdata->d_buf = xcalloc (1, xndxdata->d_size);
/* Using ELF_T_WORD here relies on the fact that the
32- and 64-bit types are the same size. */
xndxdata->d_type = ELF_T_WORD;
xndxdata->d_off = 0;
}
/* Store the real section index in the extended setion
index table. */
assert (ptr < ctx->nsymbol_tab + 1);
xshndx[ptr] = ndx;
/* And signal that this happened. */
ndx = SHN_XINDEX;
}
syment.st_shndx = ndx;
/* Remember where we put the symbol. */
sym->symidx = ptr;
(void) gelf_update_sym (data, ptr, &syment);
}
assert (ptr_local == ptr_nonlocal + 1);
shdr->sh_type = SHT_SYMTAB;
shdr->sh_link = strscnndx;
shdr->sh_info = ptr_local;
shdr->sh_entsize = gelf_fsize (ctx->out.elf, ELF_T_SYM, 1, EV_CURRENT);
(void) gelf_update_shdr (symscn, shdr);
}
/* Create the section header string table section and fill in the
references in the section headers. */
shstrscn = elf_newscn (ctx->out.elf);
data = elf_newdata (shstrscn);
shdr = gelf_getshdr (shstrscn, &shdr_mem);
if (shstrscn == NULL || data == NULL || shdr == NULL)
error (EXIT_FAILURE, 0, _("cannot create section for output file: %s"),
elf_errmsg (-1));
/* Add the name of the section header string table. */
shstrscn_strent = ebl_strtabadd (ctx->section_strtab, ".shstrtab", 10);
ebl_strtabfinalize (ctx->section_strtab, data);
shdr->sh_type = SHT_STRTAB;
assert (shdr->sh_entsize == 0);
shdr->sh_name = ebl_strtaboffset (shstrscn_strent);
(void) gelf_update_shdr (shstrscn, shdr);
/* Create the section groups. */
if (ctx->groups != NULL)
{
AsmScnGrp_t *runp = ctx->groups->next;
do
{
Elf_Scn *scn;
GElf_Shdr shdr_mem;
GElf_Shdr *shdr;
Elf_Data *data;
Elf32_Word *grpdata;
scn = runp->scn;
assert (scn != NULL);
shdr = gelf_getshdr (scn, &shdr_mem);
assert (shdr != NULL);
data = elf_newdata (scn);
if (data == NULL)
error (EXIT_FAILURE, 0,
_("cannot create section group for output file: %s"),
elf_errmsg (-1));
/* It is correct to use 'elf32_fsize' instead of 'gelf_fsize'
here. */
data->d_size = elf32_fsize (ELF_T_WORD, runp->nmembers + 1,
EV_CURRENT);
grpdata = data->d_buf = xmalloc (data->d_size);
data->d_type = ELF_T_WORD;
data->d_off = 0;
data->d_align = elf32_fsize (ELF_T_WORD, 1, EV_CURRENT);
/* The first word of the section is filled with the flag word. */
*grpdata++ = runp->flags;
if (runp->members != NULL)
{
AsmScn_t *member = runp->members->data.main.next_in_group;
do
{
/* Only sections, not subsections, can be registered
as member of a group. The subsections get
automatically included. */
assert (member->subsection_id == 0);
*grpdata++ = elf_ndxscn (member->data.main.scn);
}
while ((member = member->data.main.next_in_group)
!= runp->members->data.main.next_in_group);
}
/* Construct the section header. */
shdr->sh_name = ebl_strtaboffset (runp->strent);
shdr->sh_type = SHT_GROUP;
shdr->sh_flags = 0;
shdr->sh_link = symscnndx;
/* If the user did not specify a signature we use the initial
empty symbol in the symbol table as the signature. */
shdr->sh_info = (runp->signature != NULL
? runp->signature->symidx : 0);
(void) gelf_update_shdr (scn, shdr);
}
while ((runp = runp->next) != ctx->groups->next);
}
/* Add the name to the symbol section. */
if (likely (symscnndx != 0))
{
Elf_Scn *scn = elf_getscn (ctx->out.elf, symscnndx);
shdr = gelf_getshdr (scn, &shdr_mem);
shdr->sh_name = ebl_strtaboffset (symscn_strent);
(void) gelf_update_shdr (scn, shdr);
/* Add the name to the string section. */
assert (strscnndx != 0);
scn = elf_getscn (ctx->out.elf, strscnndx);
shdr = gelf_getshdr (scn, &shdr_mem);
shdr->sh_name = ebl_strtaboffset (strscn_strent);
(void) gelf_update_shdr (scn, shdr);
/* Add the name to the extended symbol index section. */
if (xndxscnndx != 0)
{
scn = elf_getscn (ctx->out.elf, xndxscnndx);
shdr = gelf_getshdr (scn, &shdr_mem);
shdr->sh_name = ebl_strtaboffset (xndxscn_strent);
(void) gelf_update_shdr (scn, shdr);
}
}
/* Iterate over the created sections and fill in the names. */
for (asmscn = ctx->section_list; asmscn != NULL; asmscn = asmscn->allnext)
{
shdr = gelf_getshdr (asmscn->data.main.scn, &shdr_mem);
/* This better should not fail. */
assert (shdr != NULL);
shdr->sh_name = ebl_strtaboffset (asmscn->data.main.strent);
/* We now know the maximum alignment. */
shdr->sh_addralign = asmscn->max_align;
(void) gelf_update_shdr (asmscn->data.main.scn, shdr);
}
/* Put the reference to the section header string table in the ELF
header. */
ehdr = gelf_getehdr (ctx->out.elf, &ehdr_mem);
assert (ehdr != NULL);
shstrscnndx = elf_ndxscn (shstrscn);
if (unlikely (shstrscnndx > SHN_HIRESERVE)
|| unlikely (shstrscnndx == SHN_XINDEX))
{
/* The index of the section header string sectio is too large. */
Elf_Scn *scn = elf_getscn (ctx->out.elf, 0);
/* Get the header for the zeroth section. */
shdr = gelf_getshdr (scn, &shdr_mem);
/* This better does not fail. */
assert (shdr != NULL);
/* The sh_link field of the zeroth section header contains the value. */
shdr->sh_link = shstrscnndx;
(void) gelf_update_shdr (scn, shdr);
/* This is the sign for the overflow. */
ehdr->e_shstrndx = SHN_XINDEX;
}
else
ehdr->e_shstrndx = elf_ndxscn (shstrscn);
gelf_update_ehdr (ctx->out.elf, ehdr);
/* Write out the ELF file. */
if (unlikely (elf_update (ctx->out.elf, ELF_C_WRITE_MMAP)) < 0)
{
err_libelf:
__libasm_seterrno (ASM_E_LIBELF);
return -1;
}
/* Finalize the ELF handling. */
if (unlikely (elf_end (ctx->out.elf)) != 0)
goto err_libelf;
/* Free the temporary resources. */
free (symtab);
return 0;
}
int
asm_end (ctx)
AsmCtx_t *ctx;
{
int result;
if (ctx == NULL)
/* Something went wrong earlier. */
return -1;
result = unlikely (ctx->textp) ? text_end (ctx) : binary_end (ctx);
if (result != 0)
return result;
/* Make the new file globally readable and user/group-writable. */
if (fchmod (ctx->fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) != 0)
{
__libasm_seterrno (ASM_E_CANNOT_CHMOD);
return -1;
}
/* Rename output file. */
if (rename (ctx->tmp_fname, ctx->fname) != 0)
{
__libasm_seterrno (ASM_E_CANNOT_RENAME);
return -1;
}
/* Free the resources. */
__libasm_finictx (ctx);
return 0;
}
void
__libasm_finictx (ctx)
AsmCtx_t *ctx;
{
if (unlikely (ctx->textp))
{
/* Close the stream. */
fclose (ctx->out.file);
}
else
{
/* Close the output file. */
/* XXX We should test for errors here but what would we do if we'd
find any. */
(void) close (ctx->fd);
/* XXX Iterate through section table and free individual entries. */
/* Free the resources of the hash table. */
asm_symbol_tab_free (&ctx->symbol_tab);
/* And the string tables. */
ebl_strtabfree (ctx->section_strtab);
ebl_strtabfree (ctx->symbol_strtab);
}
/* Initialize the lock. */
rwlock_fini (ctx->lock);
/* Finally free the data structure. */
free (ctx);
}

183
elfutils/libasm/asm_error.c Normal file
View File

@ -0,0 +1,183 @@
/* Error handling in libasm.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libintl.h>
#include <stdbool.h>
#include <stdlib.h>
#include "libasmP.h"
/* This is the key for the thread specific memory. */
static tls_key_t key;
/* The error number. Used in non-threaded programs. */
static int global_error;
static bool threaded;
/* We need to initialize the thread-specific data. */
once_define (static, once);
/* The initialization and destruction functions. */
static void init (void);
static void free_key_mem (void *mem);
int
asm_errno (void)
{
int result;
/* If we have not yet initialized the buffer do it now. */
once_execute (once, init);
if (threaded)
{
/* We have a key. Use it to get the thread-specific buffer. */
int *buffer = getspecific (key);
if (buffer == NULL)
{
/* No buffer allocated so far. */
buffer = (int *) malloc (sizeof (int));
if (buffer == NULL)
/* No more memory available. We use the static buffer. */
buffer = &global_error;
setspecific (key, buffer);
*buffer = 0;
}
result = *buffer;
*buffer = ASM_E_NOERROR;
return result;
}
result = global_error;
global_error = ASM_E_NOERROR;
return result;
}
void
__libasm_seterrno (value)
int value;
{
/* If we have not yet initialized the buffer do it now. */
once_execute (once, init);
if (threaded)
{
/* We have a key. Use it to get the thread-specific buffer. */
int *buffer = getspecific (key);
if (buffer == NULL)
{
/* No buffer allocated so far. */
buffer = malloc (sizeof (int));
if (buffer == NULL)
/* No more memory available. We use the static buffer. */
buffer = &global_error;
setspecific (key, buffer);
}
*buffer = value;
}
global_error = value;
}
/* Return the appropriate message for the error. */
static const char *msgs[ASM_E_NUM] =
{
[ASM_E_NOERROR] = N_("no error"),
[ASM_E_NOMEM] = N_("out of memory"),
[ASM_E_CANNOT_CREATE] = N_("cannot create output file"),
[ASM_E_INVALID] = N_("invalid parameter"),
[ASM_E_CANNOT_CHMOD] = N_("cannot change mode of output file"),
[ASM_E_CANNOT_RENAME] = N_("cannot rename output file"),
[ASM_E_DUPLSYM] = N_("duplicate symbol"),
[ASM_E_TYPE] = N_("invalid section type for operation")
};
const char *
asm_errmsg (error)
int error;
{
int last_error;
/* If we have not yet initialized the buffer do it now. */
once_execute (once, init);
if ((error == 0 || error == -1) && threaded)
{
/* We have a key. Use it to get the thread-specific buffer. */
int *buffer = (int *) getspecific (key);
if (buffer == NULL)
{
/* No buffer allocated so far. */
buffer = (int *) malloc (sizeof (int));
if (buffer == NULL)
/* No more memory available. We use the static buffer. */
buffer = &global_error;
setspecific (key, buffer);
*buffer = 0;
}
last_error = *buffer;
}
else
last_error = global_error;
if (error < -1)
return _("Unknown error");
if (error == 0 && last_error == 0)
/* No error. */
return NULL;
if (error != -1)
last_error = error;
if (last_error == ASM_E_LIBELF)
return elf_errmsg (-1);
return _(msgs[last_error]);
}
/* Free the thread specific data, this is done if a thread terminates. */
static void
free_key_mem (void *mem)
{
free (mem);
setspecific (key, NULL);
}
/* Initialize the key for the global variable. */
static void
init (void)
{
if (key_create (&key, free_key_mem) == 0)
/* Creating the key succeeded. */
threaded = true;
}

View File

@ -0,0 +1,63 @@
/* Determine fill pattern for a section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <libasmP.h>
#include <system.h>
int
asm_fill (asmscn, bytes, len)
AsmScn_t *asmscn;
void *bytes;
size_t len;
{
struct FillPattern *pattern;
struct FillPattern *old_pattern;
if (asmscn == NULL)
/* Some earlier error. */
return -1;
if (bytes == NULL)
/* Use the default pattern. */
pattern = (struct FillPattern *) __libasm_default_pattern;
else
{
/* Allocate appropriate memory. */
pattern = (struct FillPattern *) xmalloc (sizeof (struct FillPattern)
+ len);
pattern->len = len;
memcpy (pattern->bytes, bytes, len);
}
old_pattern = asmscn->pattern;
asmscn->pattern = pattern;
/* Free the old data structure if we have allocated it. */
if (old_pattern != __libasm_default_pattern)
free (old_pattern);
return 0;
}

View File

@ -0,0 +1,32 @@
/* Return ELF descriptor associated with the assembler context.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stddef.h>
#include <libasmP.h>
Elf *
asm_getelf (ctx)
AsmCtx_t *ctx;
{
return ctx != NULL ? ctx->out.elf : NULL;
}

View File

@ -0,0 +1,108 @@
/* Create new ABS symbol.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libasmP.h>
#include <system.h>
/* Object for special COMMON section. */
static const AsmScn_t __libasm_abs_scn =
{
.data = {
.main = {
.scn = ASM_ABS_SCN
}
}
};
AsmSym_t *
asm_newabssym (ctx, name, size, value, type, binding)
AsmCtx_t *ctx;
const char *name;
GElf_Xword size;
GElf_Addr value;
int type;
int binding;
{
AsmSym_t *result;
if (ctx == NULL)
/* Something went wrong before. */
return NULL;
/* Common symbols are public. Therefore the user must provide a
name. */
if (name == NULL)
{
__libasm_seterrno (ASM_E_INVALID);
return NULL;
}
rwlock_wrlock (ctx->lock);
result = (AsmSym_t *) xmalloc (sizeof (AsmSym_t));
result->scn = (AsmScn_t *) &__libasm_abs_scn;
result->size = size;
result->type = type;
result->binding = binding;
result->symidx = 0;
result->strent = ebl_strtabadd (ctx->symbol_strtab, name, 0);
/* The value of an ABS symbol must not be modified. Since there are
no subsection and the initial offset of the section is 0 we can
get the alignment recorded by storing it into the offset
field. */
result->offset = value;
if (unlikely (ctx->textp))
{
/* There is no general pseudo-op for this. We can generate
symbols of type STT_FUNC but nothing else. */
if (type == STT_FUNC)
fprintf (ctx->out.file, "\t.file \"%s\"\n", name);
}
else
{
/* Put the symbol in the hash table so that we can later find it. */
if (asm_symbol_tab_insert (&ctx->symbol_tab, elf_hash (name), result)
!= 0)
{
/* The symbol already exists. */
__libasm_seterrno (ASM_E_DUPLSYM);
free (result);
result = NULL;
}
else if (name != NULL && asm_emit_symbol_p (name))
/* Only count non-private symbols. */
++ctx->nsymbol_tab;
}
rwlock_unlock (ctx->lock);
return result;
}

View File

@ -0,0 +1,103 @@
/* Create new COMMON symbol.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libasmP.h>
#include <system.h>
/* Object for special COMMON section. */
static const AsmScn_t __libasm_com_scn =
{
.data = {
.main = {
.scn = ASM_COM_SCN
}
}
};
AsmSym_t *
asm_newcomsym (ctx, name, size, align)
AsmCtx_t *ctx;
const char *name;
GElf_Xword size;
GElf_Addr align;
{
AsmSym_t *result;
if (ctx == NULL)
/* Something went wrong before. */
return NULL;
/* Common symbols are public. Therefore the user must provide a
name. */
if (name == NULL)
{
__libasm_seterrno (ASM_E_INVALID);
return NULL;
}
rwlock_wrlock (ctx->lock);
result = (AsmSym_t *) xmalloc (sizeof (AsmSym_t));
result->scn = (AsmScn_t *) &__libasm_com_scn;
result->size = size;
/* XXX Do we have to allow a different type? */
result->type = STT_OBJECT;
/* XXX Do we have to allow a different binding? */
result->binding = STB_GLOBAL;
result->symidx = 0;
result->strent = ebl_strtabadd (ctx->symbol_strtab, name, 0);
/* The value of a COM symbol is the alignment. Since there are no
subsection and the initial offset of the section is 0 we can get
the alignment recorded by storing it into the offset field. */
result->offset = align;
if (unlikely (ctx->textp))
fprintf (ctx->out.file, "\t.comm %s, %" PRIuMAX ", %" PRIuMAX "\n",
name, (uintmax_t) size, (uintmax_t) align);
else
{
/* Put the symbol in the hash table so that we can later find it. */
if (asm_symbol_tab_insert (&ctx->symbol_tab, elf_hash (name), result)
!= 0)
{
/* The symbol already exists. */
__libasm_seterrno (ASM_E_DUPLSYM);
free (result);
result = NULL;
}
else if (name != NULL && asm_emit_symbol_p (name))
/* Only count non-private symbols. */
++ctx->nsymbol_tab;
}
rwlock_unlock (ctx->lock);
return result;
}

View File

@ -0,0 +1,203 @@
/* Create new section in output file.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include <error.h>
#include <libintl.h>
#include <stdlib.h>
#include <string.h>
#include <libasmP.h>
#include <libelf.h>
#include <system.h>
/* Memory for the default pattern. The type uses a flexible array
which does work well with a static initializer. So we play some
dirty tricks here. */
static const struct
{
struct FillPattern pattern;
char zero;
} xdefault_pattern =
{
.pattern =
{
.len = 1
},
.zero = '\0'
};
const struct FillPattern *__libasm_default_pattern = &xdefault_pattern.pattern;
static AsmScn_t *
text_newscn (AsmScn_t *result, GElf_Word type, GElf_Xword flags)
{
/* Buffer where we construct the flag string. */
char flagstr[sizeof (GElf_Xword) * 8 + 5];
char *wp = flagstr;
const char *typestr = "";
/* Only write out the flag string if this is the first time the
section is selected. Some assemblers cannot cope with the
.section pseudo-op otherwise. */
wp = stpcpy (wp, ", \"");
if (flags & SHF_WRITE)
*wp++ = 'w';
if (flags & SHF_ALLOC)
*wp++ = 'a';
if (flags & SHF_EXECINSTR)
*wp++ = 'x';
if (flags & SHF_MERGE)
*wp++ = 'M';
if (flags & SHF_STRINGS)
*wp++ = 'S';
if (flags & SHF_LINK_ORDER)
*wp++ = 'L';
*wp++ = '"';
if (type == SHT_PROGBITS)
typestr = ",@progbits";
else if (type == SHT_NOBITS)
typestr = ",@nobits";
/* Terminate the string. */
*wp = '\0';
printf ("\t.section \"%s\"%s%s\n", result->name, flagstr, typestr);
return result;
}
static AsmScn_t *
binary_newscn (AsmScn_t *result, GElf_Word type, GElf_Xword flags,
size_t scnname_len)
{
GElf_Shdr shdr_mem;
GElf_Shdr *shdr;
Elf_Scn *scn;
/* The initial subsection has the number zero. */
result->subsection_id = 0;
/* We start at offset zero. */
result->offset = 0;
/* And generic alignment. */
result->max_align = 1;
/* No output yet. */
result->content = NULL;
/* Put the default fill pattern in place. */
result->pattern = (struct FillPattern *) __libasm_default_pattern;
/* There are no subsections so far. */
result->subnext = NULL;
/* Add the name to the section header string table. */
result->data.main.strent = ebl_strtabadd (result->ctx->section_strtab,
result->name, scnname_len);
assert (result->data.main.strent != NULL);
/* Create the new ELF section. */
result->data.main.scn = scn = elf_newscn (result->ctx->out.elf);
if (scn == NULL)
{
free (result);
__libasm_seterrno (ASM_E_LIBELF);
return NULL;
}
/* Not part of a section group (yet). */
result->data.main.next_in_group = NULL;
/* Remember the flags. */
shdr = gelf_getshdr (scn, &shdr_mem);
shdr->sh_flags = flags;
result->type = shdr->sh_type = type;
(void) gelf_update_shdr (scn, shdr);
return result;
}
AsmScn_t *
asm_newscn (ctx, scnname, type, flags)
AsmCtx_t *ctx;
const char *scnname;
GElf_Word type;
GElf_Xword flags;
{
size_t scnname_len = strlen (scnname) + 1;
unsigned long int hval;
AsmScn_t *result;
/* If no context is given there might be an earlier error. */
if (ctx == NULL)
return NULL;
/* Check whether only flags are set which areselectable by the user. */
if (unlikely ((flags & ~(SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR | SHF_MERGE
| SHF_STRINGS | SHF_LINK_ORDER)) != 0)
/* We allow only two section types: data and data without file
representation. */
|| (type != SHT_PROGBITS && unlikely (type != SHT_NOBITS)))
{
__libasm_seterrno (ASM_E_INVALID);
return NULL;
}
hval = elf_hash (scnname);
rwlock_wrlock (ctx->lock);
/* This is a new section. */
result = (AsmScn_t *) xmalloc (sizeof (AsmScn_t) + scnname_len);
/* Add the name. */
memcpy (result->name, scnname, scnname_len);
/* Add the reference to the context. */
result->ctx = ctx;
/* Perform operations according to output mode. */
result = (unlikely (ctx->textp)
? text_newscn (result, type, flags)
: binary_newscn (result, type, flags, scnname_len));
/* If everything went well finally add the new section to the hash
table. */
if (result != NULL)
{
result->allnext = ctx->section_list;
ctx->section_list = result;
}
rwlock_unlock (ctx->lock);
return result;
}
INTDEF(asm_newscn)

View File

@ -0,0 +1,69 @@
/* Create new section, which is member of a group, in output file.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include "libasmP.h"
AsmScn_t *
asm_newscn_ingrp (ctx, scnname, type, flags, grp)
AsmCtx_t *ctx;
const char *scnname;
GElf_Word type;
GElf_Xword flags;
AsmScnGrp_t *grp;
{
AsmScn_t *result = __asm_newscn_internal (ctx, scnname, type, flags);
if (likely (result != NULL))
{
/* We managed to create a section group. Add it to the section
group. */
if (grp->nmembers == 0)
{
assert (grp->members == NULL);
grp->members = result->data.main.next_in_group = result;
}
else
{
result->data.main.next_in_group
= grp->members->data.main.next_in_group;
grp->members = grp->members->data.main.next_in_group = result;
}
++grp->nmembers;
/* Set the SHF_GROUP flag. */
if (likely (! ctx->textp))
{
GElf_Shdr shdr_mem;
GElf_Shdr *shdr = gelf_getshdr (result->data.main.scn, &shdr_mem);
assert (shdr != NULL);
shdr->sh_flags |= SHF_GROUP;
(void) gelf_update_shdr (result->data.main.scn, shdr);
}
}
return result;
}

View File

@ -0,0 +1,91 @@
/* Create new section group.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "libasmP.h"
#include <system.h>
AsmScnGrp_t *
asm_newscngrp (ctx, grpname, signature, flags)
AsmCtx_t *ctx;
const char *grpname;
AsmSym_t *signature;
Elf32_Word flags;
{
AsmScnGrp_t *result;
size_t grpname_len = strlen (grpname) + 1;
if (ctx == NULL)
return NULL;
if ((flags & ~GRP_COMDAT) != 0)
{
/* This is not a supported flag. */
__libasm_seterrno (ASM_E_INVALID);
return NULL;
}
result = (AsmScnGrp_t *) xmalloc (sizeof (AsmScnGrp_t) + grpname_len);
result->signature = signature;
result->members = NULL;
result->nmembers = 0;
result->flags = flags;
memcpy (result->name, grpname, grpname_len);
result->strent = ebl_strtabadd (ctx->section_strtab, result->name,
grpname_len);
if (unlikely (ctx->textp))
// XXX TBI. What is the format?
abort ();
else
{
result->scn = elf_newscn (ctx->out.elf);
if (result->scn == NULL)
{
/* Couldn't allocate a new section. */
__libasm_seterrno (ASM_E_LIBELF);
free (result);
return NULL;
}
}
/* Enqueue is the context data structure. */
if (ctx->ngroups == 0)
{
assert (ctx->groups == NULL);
ctx->groups = result->next = result;
}
else
{
result->next = ctx->groups->next;
ctx->groups = ctx->groups->next = result;
}
++ctx->ngroups;
return result;
}

View File

@ -0,0 +1,80 @@
/* Create new subsection section in given section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libasmP.h>
#include <system.h>
AsmScn_t *
asm_newsubscn (asmscn, nr)
AsmScn_t *asmscn;
unsigned int nr;
{
AsmScn_t *runp;
AsmScn_t *newp;
/* Just return if no section is given. The error must have been
somewhere else. */
if (asmscn == NULL)
return NULL;
/* Determine whether there is already a subsection with this number. */
runp = asmscn->subsection_id == 0 ? asmscn : asmscn->data.up;
while (1)
{
if (runp->subsection_id == nr)
/* Found it. */
return runp;
if (runp->subnext == NULL || runp->subnext->subsection_id > nr)
break;
runp = runp->subnext;
}
newp = (AsmScn_t *) xmalloc (sizeof (AsmScn_t));
/* Same assembler context than the original section. */
newp->ctx = runp->ctx;
/* User provided the subsectio nID. */
newp->subsection_id = nr;
/* Pointer to the zeroth subsection. */
newp->data.up = runp->subsection_id == 0 ? runp : runp->data.up;
/* We start at offset zero. */
newp->offset = 0;
/* And generic alignment. */
newp->max_align = 1;
/* No output yet. */
newp->content = NULL;
/* Inherit the fill pattern from the section this one is derived from. */
newp->pattern = asmscn->pattern;
/* Enqueue at the right position in the list. */
newp->subnext = runp->subnext;
runp->subnext = newp;
return newp;
}

View File

@ -0,0 +1,117 @@
/* Define new symbol for current position in given section.
Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libasmP.h>
#include <system.h>
AsmSym_t *
asm_newsym (asmscn, name, size, type, binding)
AsmScn_t *asmscn;
const char *name;
GElf_Xword size;
int type;
int binding;
{
#define TEMPSYMLEN 10
char tempsym[TEMPSYMLEN];
AsmSym_t *result;
if (asmscn == NULL)
/* Something went wrong before. */
return NULL;
/* Generate a temporary symbol if necessary. */
if (name == NULL)
{
/* If a local symbol name is created the symbol better have
local binding. */
if (binding != STB_LOCAL)
{
__libasm_seterrno (ASM_E_INVALID);
return NULL;
}
// XXX This requires getting the format from the machine backend. */
snprintf (tempsym, TEMPSYMLEN, ".L%07u", asmscn->ctx->tempsym_count++);
}
rwlock_wrlock (asmscn->ctx->lock);
result = (AsmSym_t *) xmalloc (sizeof (AsmSym_t));
result->scn = asmscn;
result->offset = asmscn->offset;
result->size = size;
result->type = type;
result->binding = binding;
result->symidx = 0;
result->strent = ebl_strtabadd (asmscn->ctx->symbol_strtab,
name ?: tempsym, 0);
if (unlikely (asmscn->ctx->textp))
{
/* We are only interested in the name and don't need to know whether
it is a local name or not. */
if (name == NULL)
name = tempsym;
/* First print the binding pseudo-op. */
if (binding == STB_GLOBAL)
fprintf (asmscn->ctx->out.file, "\t.globl\t%s\n", name);
else if (binding == STB_WEAK)
fprintf (asmscn->ctx->out.file, "\t.weak\t%s\n", name);
/* Next the symbol type. */
if (type == STT_OBJECT)
fprintf (asmscn->ctx->out.file, "\t.type\t%s,@object\n", name);
else if (type == STT_FUNC)
fprintf (asmscn->ctx->out.file, "\t.type\t%s,@function\n", name);
/* Finally the size and the label. */
fprintf (asmscn->ctx->out.file, "\t.size\t%s,%" PRIuMAX "\n%s:\n",
name, (uintmax_t) size, name);
}
else
{
/* Put the symbol in the hash table so that we can later find it. */
if (asm_symbol_tab_insert (&asmscn->ctx->symbol_tab,
elf_hash (name ?: tempsym), result) != 0)
{
/* The symbol already exists. */
__libasm_seterrno (ASM_E_DUPLSYM);
free (result);
result = NULL;
}
else if (name != NULL && asm_emit_symbol_p (name))
/* Only count non-private symbols. */
++asmscn->ctx->nsymbol_tab;
}
rwlock_unlock (asmscn->ctx->lock);
return result;
}

Some files were not shown because too many files have changed in this diff Show More