summaryrefslogtreecommitdiff
path: root/util/cbfstool/rmodule.c
AgeCommit message (Collapse)Author
2019-03-05rmodule: Add support for R_X86_64_PLT32Patrick Rudolph
The recent toolchain update also updated binutils, which has a new relocation type, introduced with commit bd7ab16b (x86-64: Generate branch with PLT32 relocation). Add support for R_X86_64_PLT32, which is handled as R_X86_64_PC32. Add comment explaining the situation. Fixes build error on x86_64. Change-Id: I81350d2728c20ac72cc865e7ba92319858352632 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31468 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2019-03-03rmodule: Don't emit reloc for R_X86_64_PC64Patrick Rudolph
Relocations for PC relative instructions must not emitted. As PC64 are unlikely with current code, it never was an issue. Change-Id: Ife472a287ff15b1c04a516e25ff13221441fd122 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/c/31469 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2018-12-19util/cbfstool: Support AMD64 rmodulesPatrick Rudolph
Add support for 64bit rmodule, as required for relocatable ramstage on x86_64. Change-Id: I7fbb3b4c0f76ce82c090b5f16f67a728b6bf94a5 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/c/29874 Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2018-11-22util/cbfstool/rmodule.{c,h}: Fix typo and correct headerFrans Hendriks
Header contains ':' in copyright line. rmdoule is a typo Remove the ';' and correct typo to rmodule. BUG=N/A TEST=N/A Change-Id: I05b1fb80a81682646c9fba3d234de235b6bc9e8c Signed-off-by: Frans Hendriks <fhendriks@eltan.com> Reviewed-on: https://review.coreboot.org/c/29794 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
2016-05-28util/cbfstool: Include commonlib/helpers.h in common.hFurquan Shaikh
This avoids re-declaring common macros like ARRAY_SIZE, MIN, MAX and ALIGN. Also removes the issues around including both files in any tool. Also, fix comparison error in various files by replacing int with size_t. Change-Id: I06c763e5dd1bec97e8335499468bbdb016eb28e5 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://review.coreboot.org/14978 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-10-31tree: drop last paragraph of GPL copyright headerPatrick Georgi
It encourages users from writing to the FSF without giving an address. Linux also prefers to drop that and their checkpatch.pl (that we imported) looks out for that. This is the result of util/scripts/no-fsf-addresses.sh with no further editing. Change-Id: Ie96faea295fe001911d77dbc51e9a6789558fbd6 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11888 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2015-10-29cbfstool: extract rmodules as ELFs properlyAaron Durbin
With the previous ELF stage extract support the resulting ELF files wouldn't handle rmodules correctly in that the rmodule header as well as the relocations were a part of the program proper. Instead, try an initial pass at converting the stage as if it was an rmodule first. If it doesn't work fall back on the normal ELF extraction. TEST=Pulled an rmodule out of Chrome OS shellball. Manually matched up the metadata and relocations. Change-Id: Iaf222f92d145116ca4dfaa955fb7278e583161f2 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/12222 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2015-09-22coreboot: introduce commonlibAaron Durbin
Instead of reaching into src/include and re-writing code allow for cleaner code sharing within coreboot and its utilities. The additional thing needed at this point is for the utilities to provide a printk() declaration within a <console/console.h> file. That way code which uses printk() can than be mapped properly to verbosity of utility parameters. Change-Id: I9e46a279569733336bc0a018aed96bc924c07cdd Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11592 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2015-09-16cbfstool: expose rmodule logicAaron Durbin
In order to allow cbfstool to add XIP romstage on x86 without doing the 'cbfstool locate', relink, then 'cbfstool add' dance expose the core logic and of rmodule including proving an optional filter. The filter will be used for ignoring relocations to the .car.global region. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built rambi. Change-Id: I192ae2e2f2e727d3183d32fd3eef8b64aacd92f4 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11598 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-16cbfstool: prepare for exposing rmodule logicAaron Durbin
The core logic of the rmodule parser is ideal for processing romstage ELF files for XIP. To that end start the work of exposing the logic from rmodule so cbfstool can take advantage of it. The properties that both need require: - Single program segment - Relocation information - Filter relocation processing BUG=chrome-os-partner:44827 BRANCH=None TEST=Built rambi. Change-Id: I176d0ae0ae1933cdf6adac67d393ba676198861a Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11595 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-09rmodtool: make rmodule parameter section optionalAaron Durbin
There are currently 2 uses for rmodule programs: stand alone programs that are separate from the coreboot stages and a relocatable ramstage. For the ramstage usage there's no reason to require a rmodule parameter section. Therefore make this optional. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built ramstage w/ normal linking (w/o a rmodule parameter section). No error. Change-Id: I5f8a415e86510be9409a28068e3d3a4d0ba8733e Signed-off-by: Aaron Durbin <adubin@chromium.org> Reviewed-on: http://review.coreboot.org/11523 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-09-09rmodule: use program.ld for linkingAaron Durbin
Bring rmodule linking into the common linking method. The __rmodule_entry symbol was removed while using a more common _start symbol. The rmodtool will honor the entry point found within the ELF header. Add ENV_RMODULE so that one can distinguish the environment when generating linker scripts for rmodules. Lastly, directly use program.ld for the rmodule.ld linker script. BUG=chrome-os-partner:44827 BRANCH=None TEST=Built rambi and analyzed the relocatable ramstage, sipi_vector, and smm rmodules. Change-Id: Iaa499eb229d8171272add9ee6d27cff75e7534ac Signed-off-by: Aaron Durbin <adubin@chromium.org> Reviewed-on: http://review.coreboot.org/11517 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-07-11Fix GCC 5.1 compile issue seen at Linux ArchAnatol Pomozov
rmodule.c: In function ‘rmodule_create’: rmodule.c:287:29: error: ‘phdr’ may be used uninitialized in this function [-Werror=maybe-uninitialized] (phdr->p_vaddr + phdr->p_memsz))) { ^ rmodule.c:204:14: note: ‘phdr’ was declared here Elf64_Phdr *phdr; ^ Change-Id: I94a235253610348484eef218ec855103a3bb5da5 Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> Reviewed-on: http://review.coreboot.org/10881 Tested-by: build bot (Jenkins) Reviewed-by: Francis Rowe <info@gluglug.org.uk>
2015-06-10ARM64 rmodule: Add new reloc type R_AARCH64_CONDBR19Furquan Shaikh
BUG=chrome-os-partner:41185 BRANCH=None TEST=Compiles successfully for ryu. Change-Id: I78ccc4b5ef8b49bae533e5a82323f07aaab01a7e Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: cf9d288d4bbc91301dc814408bf5e3686b869974 Original-Change-Id: I24df0eb51883a634ec3d26d46f79a059a4f8394a Original-Signed-off-by: Furquan Shaikh <furquan@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/275749 Original-Trybot-Ready: Furquan Shaikh <furquan@chromium.org> Original-Tested-by: Furquan Shaikh <furquan@chromium.org> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/10476 Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins)
2015-05-21Remove address from GPLv2 headersPatrick Georgi
As per discussion with lawyers[tm], it's not a good idea to shorten the license header too much - not for legal reasons but because there are tools that look for them, and giving them a standard pattern simplifies things. However, we got confirmation that we don't have to update every file ever added to coreboot whenever the FSF gets a new lease, but can drop the address instead. util/kconfig is excluded because that's imported code that we may want to synchronize every now and then. $ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *MA[, ]*02110-1301[, ]*USA:Foundation, Inc.:" {} + $ find * -type f -exec sed -i "s:Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA:Foundation, Inc.:" {} + $ find * -type f -exec sed -i "s:Foundation, Inc., 59 Temple Place[-, ]*Suite 330, Boston, MA *02111-1307[, ]*USA:Foundation, Inc.:" {} + $ find * -type f -exec sed -i "s:Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.:Foundation, Inc.:" {} + $ find * -type f -a \! -name \*.patch \ -a \! -name \*_shipped \ -a \! -name LICENSE_GPL \ -a \! -name LGPL.txt \ -a \! -name COPYING \ -a \! -name DISCLAIMER \ -exec sed -i "/Foundation, Inc./ N;s:Foundation, Inc.* USA\.* *:Foundation, Inc. :;s:Foundation, Inc. $:Foundation, Inc.:" {} + Change-Id: Icc968a5a5f3a5df8d32b940f9cdb35350654bef9 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/9233 Tested-by: build bot (Jenkins) Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
2015-04-25cbfstool: Clean up in preparation for adding new filesSol Boucher
This enables more warnings on the cbfstool codebase and fixes the issues that surface as a result. A memory leak that used to occur when compressing files with lzma is also found and fixed. Finally, there are several fixes for the Makefile: - Its autodependencies used to be broken because the target for the .dependencies file was misnamed; this meant that Make didn't know how to rebuild the file, and so would silently skip the step of updating it before including it. - The ability to build to a custom output directory by defining the obj variable had bitrotted. - The default value of the obj variable was causing implicit rules not to apply when specifying a file as a target without providing a custom value for obj. - Add a distclean target for removing the .dependencies file. BUG=chromium:461875 TEST=Build an image with cbfstool both before and after. BRANCH=None Change-Id: I951919d63443f2b053c2e67c1ac9872abc0a43ca Signed-off-by: Sol Boucher <solb@chromium.org> Original-Commit-Id: 49293443b4e565ca48d284e9a66f80c9c213975d Original-Change-Id: Ia7350c2c3306905984cfa711d5fc4631f0b43d5b Original-Signed-off-by: Sol Boucher <solb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/257340 Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: http://review.coreboot.org/9937 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-03-21ARM64 rmodule: Add new reloc type R_AARCH64_LDST8_ABS_LO12_NCFurquan Shaikh
BUG=chrome-os-partner:33962 BRANCH=None TEST=Compiles and boots to kernel prompt. Change-Id: Id7b0dfb5a51c2f29bdb031b98606940c118959ec Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 7a1c4d2f35c135d542708c4dabcca5e8c1d453c0 Original-Signed-off-by: Furquan Shaikh <furquan@google.com> Original-Change-Id: If132323885f23d75e1fcde064398e85c2c17f257 Original-Reviewed-on: https://chromium-review.googlesource.com/231560 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Tested-by: Furquan Shaikh <furquan@chromium.org> Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/8809 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-03-21rmodtool: add another aarch64 relocationAaron Durbin
BUG=chrome-os-partner:32112 BRANCH=None TEST=Built secmon which had this type of relocation. Change-Id: Ie367c348fbf59465e238e5fa60f217f5373501b3 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: a754bc1fe39c19ab8b2f7be9648cccb06156b0ef Original-Change-Id: If170d9e270daf3153e92d16c06516915c727e930 Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/218843 Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/8807 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-03-21rmodtool: Add support for aarch64Furquan Shaikh
BUG=chrome-os-partner:31615 BRANCH=None TEST=Compiles succesfully, rmodule created and loaded for ryu Change-Id: Icc80b845fe43a012665d77c3ef55bd30784fd3fc Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 24ad4383a9ea75ba6beb084451b74e8a8735085b Original-Change-Id: I4f3a5dbb8fc8150aa670d2e6fed56a6774feb4a6 Original-Signed-off-by: Furquan Shaikh <furquan@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/214329 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Tested-by: Furquan Shaikh <furquan@chromium.org> Original-Commit-Queue: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/8806 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-03-17cbfstool: Add relocation codes for arm modeFurquan Shaikh
Add relocation codes required for arm mode. These are required by armv4. BUG=chrome-os-partner:30784 BRANCH=None TEST=Compiles successfully for rush Original-Change-Id: Ie7c5b3e07689c85091036a619a65f9fea1918b6b Original-Signed-off-by: Furquan Shaikh <furquan@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/209973 Original-Tested-by: Furquan Shaikh <furquan@chromium.org> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Commit-Queue: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit dc5f411f95e02a02b4a4ef4652303ce62aa220c2) Signed-off-by: Marc Jones <marc.jones@se-eng.com> Change-Id: Ie62ed730080299e474c256371ab88f605b54c10f Reviewed-on: http://review.coreboot.org/8675 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-10-28rmodtool: add support for ARMAaron Durbin
Add support for creating ARM rmodules. There are 3 expected relocations for an ARM rmodule: - R_ARM_ABS32 - R_ARM_THM_PC22 - R_ARM_THM_JUMP24 R_ARM_ABS32 is the only type that needs to emitted for relocation as the other 2 are relative relocations. BUG=chrome-os-partner:27094 BRANCH=None TEST=Built vbootstub for ARM device. Original-Change-Id: I0c22d4abca970e82ccd60b33fed700b96e3e52fb Original-Signed-off-by: Aaron Durbin <adurbin@chromuim.org> Original-Reviewed-on: https://chromium-review.googlesource.com/190922 Original-Reviewed-by: Gabe Black <gabeblack@chromium.org> (cherry picked from commit a642102ba7ace5c1829abe7732199eda6646950a) Signed-off-by: Marc Jones <marc.jones@se-eng.com> Change-Id: Ib3b3c90ebb672d8d6a537df896b97dc82c6186cc Reviewed-on: http://review.coreboot.org/7204 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
2014-09-23rmodtool: Allow rmodules with 0 relocationsFurquan Shaikh
Currently, rmodules with 0 relocations are not allowed. Fix this by skipping addition of .rmodules section on 0 relocs. Change-Id: I7a39cf409a5f2bc808967d2b5334a15891c4748e Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: http://review.coreboot.org/6774 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@google.com> Tested-by: build bot (Jenkins)
2014-08-27rmodtool: correct final memory size calculationAaron Durbin
Apparently when I originally wrote this I confused myself to no end. The code/data of an rmodule has a set memory size which is associated with the .payload section. The relocation entries may increase the overall footprint of the memory size if the rmodule has no bss but a lot of relocations. Therefore, just compare relocation entries size plus the file size of the .payload section with the memory size of the paylod section. The .empty section is added only when we have not met the final target size. Change-Id: I5521dff048ae64a9b6e3c8f84a390eba37c7d0f5 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/6767 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
2014-03-20util: add rmodtool for parsing ELF files to rmodulesAaron Durbin
The current implementation of creating rmodules relies on invoking the linker in a certain manner with the relocations overlaid on the BSS section. It's not really surprising that the linker doesn't always behave the way one wants depending on the linker used and the architecture. Instead, introduce rmodtool which takes an ELF file as an input, parses it, and creates a new ELF file in the format the rmodule loader expects. Change-Id: I31ac2d327d450ef841c3a7d9740b787278382bef Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5378 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>