Commit graph

27 commits

Author SHA1 Message Date
Elyes HAOUAS
cdf7ad02c2 Fix some typos
while on it, remove unneeded white spaces.

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2022-01-09 17:34:35 +01:00
H. Peter Anvin
495fda6341 elf: support weak global and extern references
A global or extern definition can now contain the keyword "weak" (or
"strong", although that is the default) to create a weak symbol or a
weak external reference, respectively.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-09-12 14:27:50 -04:00
H. Peter Anvin (Intel)
9bb55bd127 Merge branch 'evalmacro'
Resolved Conflicts:
	asm/preproc.c
	output/elf.h
	output/outelf.c
	output/outelf.h
	version

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-04-24 11:14:43 -07:00
H. Peter Anvin
dc5939b496 Handle more ELF section types
note, preinit_array, init_array, and fini_array are ELF section types
that can matter to the assembly programmer.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-26 01:44:55 -08:00
H. Peter Anvin
b2004511dd ELF: handle more than 32,633 sections
Dead code elimination in ELF uses separate ELF sections for every
functions or data items that may be garbage collected. This can end up
being more than 32,633 sections which, when the ELF internal and
relocation sections are added in, can exceed the legacy ELF maximum of
65,279 sections.

Newer versions of the ELF specification has added support for much
larger number of sections by putting a place holder value (usually
SHN_XINDEX == 0xffff, but 0 in some cases) into fields where the
section index is a 16-bit value, and storing the full value in a
diffent place: the program header uses entries in section header 0,
the symbol table uses an auxiliary segment with the additional
indicies; the section header did not need it as the sh_link field is
already 32 (or 64) bits long.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-26 00:02:35 -08:00
H. Peter Anvin
69fa3c2e8e outelf: hash sections for performance
Use a hash table to look up sections by name, and an RAA to look up
sections by index; thus remove O(n) searches. This becomes important
since ELF uses sections for dead code elimination.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-01-12 00:35:20 -08:00
H. Peter Anvin
88477764f3 ELF: add support for the ELF "merge" attribute
Add support for the "merge" attribute in ELF, along with the
associated "strings" and size specifier attributes.

Fix a few places where we used "int", but a larger type really ought
to have been used.

Be a bit more lax about respecifying attributes. For example, align=
can be respecified; the highest resulting value is used.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-30 07:54:48 -08:00
H. Peter Anvin (Intel)
5df6ca712d With buffered warnings, change the handling of error passes
With buffered warnings, most warnings *must* be issued on every pass,
so ERR_PASS1 is simply wrong in most cases.

ERR_PASS1 now means "force this warning to be output even in
pass_first(). This is to be used for the case where the warning is
only executed in pass_first() code; this is highly discouraged as it
means the warnings will not appear in the list file and subsequent
passes may make the warning suddenly vanish.

ERR_PASS2 just as before suppresses an error or warning unless we are
in pass_final().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-18 12:25:11 -08:00
Cyrill Gorcunov
5fe4eff8c4 output: elf -- Make elf_section_attrib static
After elf files have been merged into one
no need to keep it global.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-03-25 22:15:04 +03:00
H. Peter Anvin
e562b70cea output: make the return value from the directives method more meaningful
The directives code is already trying to do a bit more unified error
handling, so give ourselves a bit richer interface.  At this point,
the conversion was pretty automatic so we probably return DIRR_OK
instead of DIRR_ERROR in a fair number of places, but that's okay.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-03-07 22:42:39 -08:00
H. Peter Anvin
e1f985c167 Reorganize the source code into subdirectories
Make the source code easier to understand and keep track of by
organizing it into subdirectories depending on the function.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2016-05-25 12:06:29 -07:00
Cyrill Gorcunov
caa18da230 out: Elf32 -- Reuse TY_DEBUGSYMLIN
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2016-04-24 20:02:40 +03:00
Cyrill Gorcunov
c24568b0b0 output: elf -- Move common structures into outelf.h header
All Elf formats we're supporting at the moment have
are using same structures, move them into a header
and name then with elf_ prefix.

This makes a few fields to carry 64 bit integers while
in former Elf32|x formats they can be 32 bit wide, but
I think it's acceptable tradeoff.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-09-21 13:03:26 +04:00
Cyrill Gorcunov
500dd5461c output: elf -- Move elf_directive into single instance
For all Elf32/32x/64 this routine is the same. So lets
merge it into one instance.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-08-29 20:30:57 +04:00
Cyrill Gorcunov
9b76c802ae output: elf -- Rename section_attrib to elf_section_attrib
Global section_attrib name is too general.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2014-08-29 20:24:24 +04:00
Cyrill Gorcunov
d7b654c73d elf: Move stabs symbol table format into outelf.h
Get rid of code duplication

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-07-30 00:51:44 +04:00
Cyrill Gorcunov
d807d911fe Elf: Rename SEG_ALIGN to SEC_FILEALIGN
It's Elf specifics. To not mess with segment alignment.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-21 01:06:44 +04:00
Cyrill Gorcunov
e3c4791300 Elf: Merge WRITE_STAB to outelf.h
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:10:20 +04:00
Cyrill Gorcunov
572dd0021c Elf: Introduce section_attrib helper
In a sake of removing code duplication.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-04-10 00:02:38 +04:00
Cyrill Gorcunov
3cbd9e7215 Elf: Drop useless SEG_ALIGN_1
No need for SEG_ALIGN_1 since we have switched
to ALIGN helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-02-11 21:28:34 +03:00
Cyrill Gorcunov
a135658e83 ELF: Explicitly point out SYM_GLOBAL, SYM_LOCAL binding
Instead of implicit declaration of global symbols obtained
by STB_GLOBAL << 4, and local symbols by STB_LOCAL << 4
use ELF32_ST_MKBIND helpers.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:46 +03:00
Cyrill Gorcunov
126faf2e3b output/outelfX.c: Use definitions from stabs.h
Also made Makefile.in to handle dependency.
There are some makefiles in Mkfiles\ should
be fixed as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2010-01-03 15:04:36 +03:00
Cyrill Gorcunov
2cff224e4b output/outelf.h - tab-space cleanup
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2009-09-03 19:04:23 +04:00
H. Peter Anvin
d7392ad814 Add new copyright headers to the output modules
Add new copyright headers to the new output modules.  As far as I
know, the only module which we still don't have a green light to
release under 2-BSD is outmacho.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-28 17:25:15 -07:00
H. Peter Anvin
3716238058 ELF: bump GLOBAL_TEMP_BASE
Bump GLOBAL_TEMP_BASE so far that it *cannot* conflict for ELF32
(which has 24-bit symbol table indicies) and is *unlikely* to conflict
for ELF64 (which has 32-bit symbol table indicies.)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 17:25:35 -07:00
H. Peter Anvin
c4471462dc ELF: eliminate hard-coded section numbers
Eliminiate hard-coded section numbers, at least to the best of our
ability.  There is still a very odd piece of computation in
elf_build_reltab() which I can't really figure out...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 14:54:44 -07:00
H. Peter Anvin
d219a3e46f ELF: add header files, begin merging common code, drop .comment
Add something approaching real ELF header files.

Begin merging the common ELF code, beginning with the section name
detection.

Drop automatic generation of .comment section, and in particular the
treatment of .common as a special section (if we decide generating
.comment is still a good idea, we should just do it as a macro.)

Augment the list of known sections, and make it table-driven.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 12:30:50 -07:00