summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2023-05-24 22:05:50 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-06-01 10:53:35 +0000
commit7ffc433c2ec1db3a600ad78ba4c44d863991967f (patch)
tree2cd696173af818ab2a171ff546befba3b88d8ab0
parentc1e853769046b322690ad336fdb98966757e7414 (diff)
downloadedk2-7ffc433c2ec1db3a600ad78ba4c44d863991967f.tar.gz
edk2-7ffc433c2ec1db3a600ad78ba4c44d863991967f.tar.bz2
edk2-7ffc433c2ec1db3a600ad78ba4c44d863991967f.zip
BaseTools: make sure the got is empty
Add ASSERT()s that .got and .got.plt sections are empty to linker scripts for gcc and clang. Suggested-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
-rw-r--r--BaseTools/Scripts/ClangBase.lds10
-rw-r--r--BaseTools/Scripts/GccBase.lds10
2 files changed, 20 insertions, 0 deletions
diff --git a/BaseTools/Scripts/ClangBase.lds b/BaseTools/Scripts/ClangBase.lds
index 61452ddd95..c7dcd2024a 100644
--- a/BaseTools/Scripts/ClangBase.lds
+++ b/BaseTools/Scripts/ClangBase.lds
@@ -59,6 +59,16 @@ SECTIONS {
KEEP (*(.hii))
}
+ .got : {
+ *(.got)
+ }
+ ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
+
+ .got.plt (INFO) : {
+ *(.got.plt)
+ }
+ ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
+
/*
* Retain the GNU build id but in a non-allocatable section so GenFw
* does not copy it into the PE/COFF image.
diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds
index 83cebd29d5..9f27e83bb0 100644
--- a/BaseTools/Scripts/GccBase.lds
+++ b/BaseTools/Scripts/GccBase.lds
@@ -59,6 +59,16 @@ SECTIONS {
KEEP (*(.hii))
}
+ .got : {
+ *(.got)
+ }
+ ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
+
+ .got.plt (INFO) : {
+ *(.got.plt)
+ }
+ ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!")
+
/*
* Retain the GNU build id but in a non-allocatable section so GenFw
* does not copy it into the PE/COFF image.