summaryrefslogtreecommitdiff
path: root/include/linker_lists.h
AgeCommit message (Collapse)AuthorFilesLines
2023-04-04linker_lists: Rework start/end macros to not rely on undefined behaviorTom Rini1-4/+12
Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems. Reported-by: AdityaK <appujee@google.com> Suggested-by: Andrew Pinski <apinski@marvell.com> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108915 Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Andrew Pinski <apinski@marvell.com>
2022-06-23linker_lists: Rename sections to remove . prefixAndrew Scull1-9/+9
Rename the sections used to implement linker lists so they begin with '__u_boot_list' rather than '.u_boot_list'. The double underscore at the start is still distinct from the single underscore used by the symbol names. Having a '.' in the section names conflicts with clang's ASAN instrumentation which tries to add redzones between the linker list elements, causing expected accesses to fail. However, clang doesn't try to add redzones to user sections, which are names with all alphanumeric and underscore characters. Signed-off-by: Andrew Scull <ascull@google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24treewide: Convert macro and uses of __section(foo) to __section("foo")Marek BehĂșn1-12/+12
This commit does the same thing as Linux commit 33def8498fdd. Use a more generic form for __section that requires quotes to avoid complications with clang and gcc differences. Remove the quote operator # from compiler_attributes.h __section macro. Convert all unquoted __section(foo) uses to quoted __section("foo"). Also convert __attribute__((section("foo"))) uses to __section("foo") even if the __attribute__ has multiple list entry forms. Signed-off-by: Marek BehĂșn <marek.behun@nic.cz> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-10linker_lists: document ll_entry_ref parametersHeinrich Schuchardt1-0/+4
Avoid 'make htmldocs' build warnings: ./include/linker_lists.h:224: warning: Function parameter or member '_type' not described in 'll_entry_ref' ./include/linker_lists.h:224: warning: Function parameter or member '_name' not described in 'll_entry_ref' ./include/linker_lists.h:224: warning: Function parameter or member '_list' not described in 'll_entry_ref' Fixes: 851144350b6f ("linker_lists: Allow use in data structures") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-03-22dm: core: Add macros to access the new linker listsSimon Glass1-2/+2
Add macros which work with instantiated devices and uclasses, as created at build time by dtoc. Include variants that can be used in data structures. These are mostly used by dtoc but it is worth documenting them fully for the occasional case where they might come up in user code. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22linker_lists: Allow use in data structuresSimon Glass1-0/+12
At present linker lists are designed for use in code. They make use of statements within expressions ({...}), for example. It is possible to generate a reference to a linker_list entry that can be used in data structures, where such features are not permitted. It requires that the reference first be declared as extern. In other words the existing macro needs to be split into two parts. Add new macros to support this. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-19linker_lists: Fix alignment issueSimon Glass1-1/+2
The linker script uses alphabetic sorting to group the different linker lists together. Each group has its own struct and potentially its own alignment. But when the linker packs the structs together it cannot ensure that a linker list starts on the expected alignment boundary. For example, if the first list has a struct size of 8 and we place 3 of them in the image, that means that the next struct will start at offset 0x18 from the start of the linker_list section. If the next struct has a size of 16 then it will start at an 8-byte aligned offset, but not a 16-byte aligned offset. With sandbox on x86_64, a reference to a linker list item using ll_entry_get() can force alignment of that particular linker_list item, if it is in the same file as the linker_list item is declared. Consider this example, where struct driver is 0x80 bytes: ll_entry_declare(struct driver, fred, driver) ... void *p = ll_entry_get(struct driver, fred, driver) If these two lines of code are in the same file, then the entry is forced to be aligned at the 'struct driver' alignment, which is 16 bytes. If the second line of code is in a different file, then no action is taken, since the compiler cannot update the alignment of the linker_list item. In the first case, an 8-byte 'fill' region is added: .u_boot_list_2_driver_2_testbus_drv 0x0000000000270018 0x80 test/built-in.o 0x0000000000270018 _u_boot_list_2_driver_2_testbus_drv .u_boot_list_2_driver_2_testfdt1_drv 0x0000000000270098 0x80 test/built-in.o 0x0000000000270098 _u_boot_list_2_driver_2_testfdt1_drv *fill* 0x0000000000270118 0x8 .u_boot_list_2_driver_2_testfdt_drv 0x0000000000270120 0x80 test/built-in.o 0x0000000000270120 _u_boot_list_2_driver_2_testfdt_drv .u_boot_list_2_driver_2_testprobe_drv 0x00000000002701a0 0x80 test/built-in.o 0x00000000002701a0 _u_boot_list_2_driver_2_testprobe_drv With this, the linker_list no-longer works since items after testfdt1_drv are not at the expected address. Ideally we would have a way to tell gcc not to align structs in this way. It is not clear how we could do this, and in any case it would require us to adjust every struct used by the linker_list feature. One possible fix is to force each separate linker_list to start on the largest possible boundary that can be required by the compiler. However that does not seem to work on x86_64, which uses 16-byte alignment in this case but needs 32-byte alignment. So add a Kconfig option to handle this. Set the default value to 4 so as to avoid changing platforms that don't need it. Update the ll_entry_start() accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-23doc: Replace DocBook with sphinx-based docsMario Six1-111/+53
The Linux kernel moved to sphinx-based documentation and got rid of the DocBook based documentation quite a while ago. Hence, the DocBook documentation for U-Boot should be converted as well. To achieve this, import the necessary files from Linux v4.17, and convert the current DocBook documentation (three files altogether) to sphinx/reStructuredText. For now, all old DocBook documentation was merged into a single handbook, tentatively named "U-Boot Hacker Manual". For some source files, the documentation style was changed to comply with kernel-doc; no functional changes were applied. Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-09-07linker_lists: remove incorrect commentHeinrich Schuchardt1-2/+1
Remove a comment line refering to a non-existent file. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2015-07-28Fix incorrect comments in linker_lists.hBin Meng1-10/+10
This corrects several typos in the comment block as well as some indentions and nits in the linker_lists.h. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2015-04-18linker_lists: Add a function to access a linker list entrySimon Glass1-0/+10
Once declared, you cannot access a linker_list entry since you do not have a symbol name for it. Add llsym() macro to provide this. This avoids searching for the symbol at run-time based on name. An example usage is to declare a driver with U_BOOT_DRIVER(), then obtain a pointer to that driver later. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
2015-01-29linker_lists: fix misspellingsGuilherme Maciel Ferreira1-2/+2
Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
2014-10-22dm: linker_lists: Add a way to declare multiple objectsSimon Glass1-0/+21
The existing ll_entry_declare() permits a single element of the list to be added to a linker list. Sometimes we want to add several objects at once. To avoid lots of messy declarations, add a macro to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-10-22linker_lists: include <linux/compiler.h>Masahiro Yamada1-0/+2
The header file include/linker_lists.h uses __aligned(); therefore it depends on include/linux/compiler.h Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Simon Glass <sjg@chromium.org>
2014-09-25linker_lists: fix commentMasahiro Yamada1-2/+2
The section name and the C variable name seem to be opposite. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Cc: Marek Vasut <marex@denx.de> Acked-by: Marek Vasut <marex@denx.de>
2014-05-05common: fixed linker-list exampleMateusz Zalega1-1/+1
Last argument shouldn't be there. Signed-off-by: Mateusz Zalega <m.zalega@samsung.com> Acked-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@ti.com>
2014-02-19kernel-doc: fix some errorsMasahiro Yamada1-3/+3
- Delete fs.xml from DOCBOOKS to fix an error. Commit e3ff797c added fs.xml to DOCBOOKS but missed to add doc/DocBook/fs.tmpl. - Fix the location of include guard in include/linker_lists.h. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Reported-by: Abraham Varricatt <abraham.varricatt@vvdntech.com> Acked-by: Simon Glass <sjg@chromium.org>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk1-7/+1
Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
2013-03-13Refactor linker-generated arraysAlbert ARIBAUD1-53/+199
Refactor linker-generated array code so that symbols which were previously linker-generated are now compiler- generated. This causes relocation records of type R_ARM_ABS32 to become R_ARM_RELATIVE, which makes code which uses LGA able to run before relocation as well as after. Note: this affects more than ARM targets, as linker- lists span possibly all target architectures, notably PowerPC. Conflicts: arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds arch/arm/cpu/armv7/omap-common/u-boot-spl.lds board/ait/cam_enc_4xx/u-boot-spl.lds board/davinci/da8xxevm/u-boot-spl-da850evm.lds board/davinci/da8xxevm/u-boot-spl-hawk.lds board/vpac270/u-boot-spl.lds Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
2012-10-22common: Implement support for linker-generated arraysMarek Vasut1-0/+148
This patch adds support for linker-generated array. These arrays are a generalization of the U-Boot command declaration approach. Basically, the idea is to generate an array, where elements of the array are statically initialized at compile time and each element is declared separatelly at different place. Such array is assembled together into continuous piece of memory by linker and a pointer to it's first entry can then be retrieved via accessor. The actual implementation relies on placing any variable that is to represent an element of LG-array into particular subsection of the .u_boot_list linker section . The subsection is determined by user options. Once compiled, it is possible to dump all symbols placed in .u_boot_list section and the subsections in which they should be and generate appropriate bounds for each requested subsection of the .u_boot_list section. Each such subsection thus contains __start and __end entries at the begining and end respecitively. This allows for simple run-time traversing of the array, since the symbols are properly defined. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Joe Hershberger <joe.hershberger@gmail.com> Cc: Mike Frysinger <vapier@gentoo.org>