summaryrefslogtreecommitdiff
path: root/output
Commit message (Collapse)AuthorAgeFilesLines
* outlib: Make ol_add_sym_to being staticCyrill Gorcunov2020-07-031-2/+2
| | | | | | | | | | Otherwise getting building problem > output/outlib.c:197:6: error: no previous prototype for ‘ol_add_sym_to’ [-Werror=missing-prototypes] > 197 | void ol_add_sym_to(struct ol_symlist *syml, struct ol_symhead *head, > | ^~~~~~~~~~~~~ Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* outlib: fix infinite recursion due to incorrect wrappingH. Peter Anvin (Intel)2020-07-021-1/+1
| | | | | | | | | recursion: see recursion. A wrapper function needs to call the function being wrapped, not itself. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* outlib: add infrastructure for common section and symbol handlingH. Peter Anvin (Intel)2020-06-272-8/+522
| | | | | | | | | | | | | | Pretty much all the backends have to do the same gymnastics to handle symbols and sections. In the future, this should be done by the assembly core, but in order to prepare the ground and get the performance benefits as soon as possible, implement a library of functions which can manage symbols and sections and their respective hashes, trees, and tables. This infrastructure is not yet used by any backend, that porting work has to come next. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* DWARF: consistent version information; drop .debug_loc sectionH. Peter Anvin (Intel)2020-06-261-23/+111
| | | | | | | | | Fix the version information for various sections and generalize their implementation. Drop issuing an empty .debug_pubnames section; like other sections DWARF parsers seem to be unhappy about a section with null content. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* dwarf: don't emit a dummy .debug_loc sectionH. Peter Anvin (Intel)2020-06-261-14/+16
| | | | | | | | It seems DWARF parsers get really snippy about a section which only contains an end token. Instead, leave unused sections empty. Already did that with .debug_frame, do it with .debug_loc too. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392650: Codeview truncates symbol table length to 16 bitsH. Peter Anvin (Intel)2020-06-261-9/+9
| | | | | | | | | | If the source code is large, it is very reasonable for the symbol table length to exceed 2^16 bits. Use uint32_t to keep track of lengths, even where not necessary... there is no real reason to use uint16_t anywhere. Reported-by: <michael@mehlich.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392651: fix the .debug$T section in Codeview output formatH. Peter Anvin (Intel)2020-06-251-24/+20
| | | | | | | | | | | | | | The cv8 output format would generate an invalid .debug$T section, containing repeated invalid records, none of which are actually used (which is probably the only reason it actually worked.) Just in case, generate a *single* type record for void func(void); Furthermore, the argument list record should come before the procedure type record (forward references are at least normatively prohibited.) Reported-by: Alexandre Ganea <alexandre.ganea@ubisoft.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* BR 3392657: dwarf: leave .debug_frame emptyH. Peter Anvin (Intel)2020-06-141-3/+8
| | | | | | | | Until such time that we have a CFI code generator, leave .debug_frame empty. Reported-by: Philip Craig <philipjcraig@gmail.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* outobj: fix harmless but still incorrect use of uninitialized variableH. Peter Anvin2020-06-011-3/+3
| | | | | | | Fix use of uninitialized variable. This most likely is just an issue while running at debug level >= 3, but it's still wrong. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* outelf: Fix the section index for the debug outputChang S. Bae2020-04-221-3/+6
| | | | | | | | | | | | | | | The section information delivered to the debug output has an index of the section table. The index should be different from the total number of sections at the moment, the returned value from add_sectname(). So, fix the value. Fixes: b2004511ddde ("ELF: handle more than 32,633 sections") Reported-by: C. Masloch <pushbx@ulukai.org> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392654 Reported-by: <mae.bdf@outlook.com> Link: https://bugzilla.nasm.us/show_bug.cgi?id=3392661 Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* outcoff: add semi-generic pragma namespacesH. Peter Anvin2019-09-301-4/+15
| | | | | | | Recognize the semi-generic pragma namespaces "coff" and "win" for the win32 and win64 backends. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* outelf: use "symbols" not "variables" in error messagesH. Peter Anvin2019-09-121-1/+1
| | | | | | | Many symbols are variables, but others are labels, etc. Use the common term "symbol". Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* elf: fix "object" symbol keywordH. Peter Anvin2019-09-121-1/+1
| | | | | | | | | The "object" symbol keyword would incorrectly generate STT_NOTYPE instead of STT_OBJECT. Add test for weak object references; they are different from plain weak references in that they are guaranteed to resolve to zero if the symbol is not found. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Change LBL_NONE to LBL_noneH. Peter Anvin2019-09-122-3/+3
| | | | | | | | | | | NASM convention is to use all-upper-case for "real" information, and mixed-case (upper case common prefix, lower case description) for meta-information. This is a highly useful distinction. Thus "LBL_NONE" implies an actual label of type "NONE", as opposed to no label at all. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Drop unnecessary EXTERN symbolsH. Peter Anvin2019-09-122-4/+4
| | | | | | | | | | | | Currently, NASM always issues as an unknown symbol any symbol declared EXTERN. This is highly undesirable when using common header files, as it might cause the linker to pull in a bunch of unnecessary modules, depending on how smart the linker is. Add a new REQUIRED directive which behaves like the old EXTERN, for the use cases which might still need this behavior. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* elf: support weak global and extern referencesH. Peter Anvin2019-09-122-94/+135
| | | | | | | | 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>
* preproc: standard macros now C-safe, %aliases off, fix %? recursionH. Peter Anvin2019-08-2710-22/+22
| | | | | | | | | | | | | | | | | | | | Enough users expect the namespace starting with underscore to be safe for symbols. Change our private namespace from __foo__ to __?foo?__. Use %defalias to provide backwards compatiblity (by using %defalias instead of %define, we handle the case properly where the user changes the value.) Add a preprocessor directive: %aliases off ... to disable all smacro aliases and thereby making the namespace clean. Finally, fix infinite recursion when seeing %? or %?? due to paste_tokens(). If we don't paste anything, the expansion is done. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* outelf: change debug format default to dwarfH. Peter Anvin2019-08-101-3/+3
| | | | | | | DWARF is by far the predominant format on ELF platforms these days. Catch up with the times. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Clean up backend format namesH. Peter Anvin2019-08-1010-42/+30
| | | | | | | The backend format names were rather redundant and not always helpful. Do some cleanup. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Additional listing options, improve help output, fix macro limitsH. Peter Anvin2019-08-103-11/+28
| | | | | | | | | | | | | | | | | | Additional listing options: -Ld to display counts in decimal -Lp to output a list file in every pass (to make sure one exists) Clean up the help output and make it comprehensive. The -hf and -y options are no longer necessary, although they are supported for backwards compatiblity. Fix macro-levels so it actually count descent levels; a new macro-tokens limit introduced for the actual token limit. Slightly simplify the limits code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Diagnostics: make debug more dynamic, note -> info, add listmsg levelH. Peter Anvin (Intel)2019-08-093-23/+22
| | | | | | | | | | | | | | | | Make debug messages more dynamic by making it easy to conditionalize the messages. Change ERR_NOTE to ERR_INFO which reflects the usage better. Other compilers use note: for additional information. Don't unwind the macro stack with ERR_HERE; it is only going to give confusing results as it will unwind the wrong macro stack. Add ERR_LISTMSG level which is *always* suppressed, but will still appear in the list file. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* outmacho.c: mark zeroing warning as WARN_ZEROINGH. Peter Anvin (Intel)2019-08-061-1/+1
| | | | | | The zeroing warning should, amazingly enough, have been WARN_ZEROING. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Replace nasm_error(ERR_WARNING|...) with nasm_warn()H. Peter Anvin (Intel)2019-08-062-7/+7
| | | | | | Remove a few remaining instances of nasm_error(ERR_WARNING). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Add group aliases for all prefixed warnings.H. Peter Anvin2019-06-061-1/+1
| | | | | | | For example, -w+float will now enable all warnings with names staring with float-*. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* outelf: get rid of long-since-obsolete gnu extensions warningH. Peter Anvin2019-06-061-32/+26
| | | | | | | R_386_[PC]{8,16} have been part of the official ELF32 spec for a very long time now. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* outbin: Fix infinite dashes written to map fileChang S. Bae2019-06-021-0/+1
| | | | | | | | | | | | Unfortunately, there is an assumption that the section name is bounded to '65' characters and dashes have been appended so far. A simple fix for this report: https://bugzilla.nasm.us/show_bug.cgi?id=3392564 We may need to cleanup further for those hardcoded numbers in decorating the section info. Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
* Merge branch 'evalmacro'H. Peter Anvin (Intel)2019-04-243-659/+827
|\ | | | | | | | | | | | | | | | | | | | | 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>
| * ELF: the .note section should be 4-byte alignedH. Peter Anvin2019-02-261-1/+1
| | | | | | | | | | | | | | The ELF .note section contains of 4-byte words and should be aligned accordingly. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * Handle more ELF section typesH. Peter Anvin2019-02-262-69/+115
| | | | | | | | | | | | | | 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>
| * ELF: handle more than 32,633 sectionsH. Peter Anvin2019-02-263-551/+549
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * outelf: hash sections for performanceH. Peter Anvin2019-01-122-28/+50
| | | | | | | | | | | | | | | | 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>
| * ELF: add support for the ELF "merge" attributeH. Peter Anvin2018-12-302-33/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * warnings: rename ERR_WARN_* to WARN_*H. Peter Anvin (Intel)2018-12-122-3/+3
| | | | | | | | | | | | | | | | The prefix ERR_WARN_ is unnecessarily long and may be a disincentive to create new warning categories. Change it to WARN_*, it is still plenty distinctive. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Warnings: move zeroing reserved space to a separate warning classH. Peter Anvin (Intel)2019-01-115-7/+7
| | | | | | | | | | | | | | Zeroing reserved space in a progbits section really should be a separate warning class, so it can be controlled independently. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Remove #includes already provided by "compiler.h"H. Peter Anvin2018-12-2712-27/+0
| | | | | | | | | | | | | | | | "compiler.h" already includes a bunch of common include files. There is absolutely no reason to duplicate them in individual files, and in fact it robs us of central control of how these files are used. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Replace <ctype.h> includes with "nctype.h"H. Peter Anvin2018-12-2710-10/+12
| | | | | | | | | | | | | | For almost everything we should use "nctype.h". Right now we don't have a nasm_toupper() to use <ctype.h> for things that need toupper(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Move <string.h> inclusion to compiler.hH. Peter Anvin2018-12-2610-10/+0
| | | | | | | | | | | | | | There is absolutely no reason not to include <string.h> globally, and with the inline function for mempcpy() we need it there anyway. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | elf.h: add relocation numbers for segmented supportH. Peter Anvin2018-12-241-1/+4
| | | | | | | | | | | | | | Add relocation numbers reserved/intended for segmented support in ELF32. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | With buffered warnings, change the handling of error passesH. Peter Anvin (Intel)2018-12-187-39/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Clean up the handling of various passesH. Peter Anvin (Intel)2018-12-1812-95/+87
| | | | | | | | | | | | | | | | | | The use of pass0, pass1, pass2, and "pass" passed as an argument is really confusing and already caused a severe bug in the 2.14.01 release cycle. Clean them up and be far more explicit about what various passes mean. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | nasm_assert(): try to run at compile time if possibleH. Peter Anvin (Intel)2018-12-142-3/+3
| | | | | | | | | | | | | | | | | | | | Try to make nasm_assert() do a static assert if the argument can be evaluated at compile time by any particular compiler. We also provide nasm_try_static_assert() which will assert a compile-time expression if and only if we can determine we have a constant at compile time *and* we know that the compiler has a way to handle it. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: make WARN_* constant obligatory for warningsH. Peter Anvin (Intel)2018-12-141-6/+6
| | | | | | | | | | | | Make it an error to have ERR_WARNING without a suppression level. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | nasm_warnf() -> nasm_warn()H. Peter Anvin (Intel)2018-12-147-33/+33
| | | | | | | | | | | | | | | | We want to strongly encourage writers of warnings to create warning categories, so remove the flagless nasm_warn() and change nasm_warnf() to nasm_warn(). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: define warning classes at point of usemkwarningsH. Peter Anvin (Intel)2018-12-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | It is extremely desirable to allow the user fine-grained control of warnings, but this has been complicated by the fact that a warning class has had to be defined in no less than three places (error.h, error.c, nasmdoc.src) before it can be used in source code. Instead, use a script to define these via magic comments at the point of use. This hopefully will encourage creating new classes as needed. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: Make WARN_ constants consistent with -w optionsH. Peter Anvin (Intel)2018-12-121-2/+2
| | | | | | | | | | | | Not only does this make it consistent, but allows for automation. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: rename ERR_WARN_* to WARN_*H. Peter Anvin (Intel)2018-12-122-3/+3
| | | | | | | | | | | | | | | | | | | | The prefix ERR_WARN_ is unnecessarily long and may be a disincentive to create new warning categories. Change it to WARN_*, it is still plenty distinctive. This is equivalent to nasm-2.14.xx checkin 77f53ba6d4cb90e5a7e09b33357ed7c1fe9f6b9d. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | strlist: merge the strtbl and strlist interfacesH. Peter Anvin (Intel)2018-12-113-175/+1
| | | | | | | | | | | | | | | | The currently-unused strtbl was basically a slightly different version of strlist, with the find and linearize capabilities. Merge these two together by augmenting strlist to have the same capabilities. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | hashtbl: revamp the hash table interface, support binary keysH. Peter Anvin (Intel)2018-12-113-10/+8
| | | | | | | | | | | | | | Add binary key support to the hash table interface. Clean up the interface to contain less extraneous crud. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | output: elf -- Use nasm_error helpersCyrill Gorcunov2018-12-021-117/+107
| | | | | | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | output: obj -- Use nasm_error helpersCyrill Gorcunov2018-12-021-77/+63
| | | | | | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>