aboutsummaryrefslogtreecommitdiff
path: root/arm-link.c
Commit message (Collapse)AuthorAgeFilesLines
* elf: Support STB_LOCAL dynamic symbolsMichael Matz2017-05-071-0/+1
| | | | | | | | local symbols can be resolved statically, they don't have to be done dynamically, so this is a slight speedup at load time for produced executables and shared libs. The musl libc also rejects any STB_LOCAL symbols for dynamic symbol resolution, so there it also fixes use of shared libs created by tcc.
* tcc: fixup clang warningsAndrei Warkentin2017-04-251-1/+1
| | | | | | | | | | | The O(xxx) stuff in i386-asm.c had me scratching my head. Extracting the macro and trying it out in a separate program doesn't give me any warnings, so I'm confused about what could be going on there. Any cast will make things happy. I used a uint64_t to catch actual cases of overflow, which will still cause a -Wconstant-conversion warning. Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
* tccelf: some linker cleanupgrischka2016-12-151-1/+64
| | | | | | | | | | - generate and use SYM@PLT for plt addresses - get rid of patch_dynsym_undef hack (no idea what it did on FreeBSD) - use sym_attrs instead of symtab_to_dynsym - special case for function pointers into .so on i386 - libtcc_test: test tcc_add_symbol with data object - move target specicic code to *-link.c files - add R_XXX_RELATIVE (needed for PE)
* Use functions to get relocation infoThomas Preud'homme2016-12-101-23/+74
| | | | | | | MSVC does not support array designator so cannot compile source using relocs_info. This commit replace the relocs_info array into a set of functions, each returning the value given by a given field of the struct reloc_info.
* Remove now useless pltoff_addend reloc infoThomas Preud'homme2016-12-101-21/+21
| | | | | | Last use for pltoff_addend field of relocs_info array was removed in commit 25927df3b75c5ce2b64ab8acdcc5974b4e1c89c1. It is now useless so this commit removes it and all initialization related to it.
* Fix PLT creation for i386Thomas Preud'homme2016-12-101-0/+1
| | | | | | | | | | | | | | | | | | | i386 target does not have PC relative loads. Its ABI therefore require ebx register to points to the GOT when executing a PLT entry. This means that PLT entry cannot be used transparently, the compiler needs to expect execution of a PLT entry to be able to use one, that is a PLT entry should only be created if the relocation explicitely asks for it (eg. R_386_PLT32). This patch creates a new target macro PCRELATIVE_DLLPLT to indicate whether a target can do a PC relative load in PLT entry when building a dynamic library. Executable do not normally pose a problem because they are loaded at a fixed address and thus the absolute address of GOT can be used. Note that in such a case, if the compiler does not use a PLT aware relocation for external access then the code relocation will fall on the dynamic loader since there is no PLT entry to relocate too.
* Fix relocs_info declaration in tcc.hThomas Preud'homme2016-12-051-2/+28
| | | | | | | | | C standard specifies that array should be declared with a non null size or with * for standard array. Declaration of relocs_info in tcc.h was not respecting this rule. This commit add a R_NUM macro that maps to the R_<ARCH>_NUM macros and declare relocs_info using it. This commit also moves all linker-related macros from <arch>-gen.c files to <arch>-link.c ones.
* Consolidate all relocations in relocate_sectionThomas Preud'homme2016-12-031-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Static relocation of functions in dynamic libraries must use the PLT entry as the target. Before this commit, it used to be done in 2 parts for ARM, with the offset of the PLT entry from the beginning of the PLT being put in the relocated place in build_got_entries () and then the address of the PLT being added in relocate_section. This led to code dealing with reading the offset of a bl instruction in build_got_entries. Furthermore, the addition of the address of the start of the PLT was done based on the relocation type which does not convey whether a PLT entry should be used to reach the symbol. This commit moves the decision to use the PLT as the target in relocate_section, therefore having the instruction aware code contained to the target-specific bit of that function (in <target>-link.c). Note that relocate_syms is *not* the right place to do this because two different relocations for the same symbol can make different decision. This is the case in tcc -run mode where the static and dynamic relocation are done by tcc. Storing the PLT entry address in the symbol's st_value field and relying on the specific relocation type being used for dynamic relocation would work but the PLT entry address would then appear in the static symbol table (symtab). This would also make the static symbol table entry differ from the dynamic symbol table entry.
* Consolidate GOT creation in build_got_entriesThomas Preud'homme2016-12-031-1/+1
| | | | | | | | | | | | | | | | | | Currently GOT/PLT creation happens in two locations depending on whether the GOT/PLT [entry] is required by the symbol or the relocation: - bind_exe_dynsym for relocations to undefined symbol - build_got_entries/put_got_entry for relocations that require a GOT/PLT entry This commit consolidate GOT/PLT creation in build_got_entries by reducing bind_exe_dynsym's job to create a dynamic symbol for undefined symbols. build_got_entries then invoke put_got_entry if the symbol being relocated is undefined or the relocation asks for a PLT or GOT [entry]. put_got_entry is also modified to only export a symbol in the dynamic symbol table when we are in the case of PLT/GOT [entry] required by the relocation (since undefined symbol are already exported by bind_exe_dynsym).
* Make build_got_entries more target independentThomas Preud'homme2016-12-031-2/+52
| | | | | Factor most of common logic between targets in build_got_entries by defining target specific info into structures in the backends.
* Do section relocation in architecture backendThomas Preud'homme2016-12-031-0/+204