mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
Previously, the actual behavior of magic lookup and one described in its commit description have not matched. Instead of being weak definitions in a library that is always in the end of load order, the definitions were normal ones and thus were able to override other weak definitions in LibC. While this was consistent with how DynamicLoader resolves ambiguity between normal and weak relocations, this is not the behavior POSIX mandates -- we should always choose first available definition wrt load order. To fix this problem, the patch makes sure we don't define any of magic symbols in LibC. In addition to this, it makes all provided magic symbols functions (instead of objects), what renders MagicWeakSymbol class unnecessary.
16 lines
505 B
C++
16 lines
505 B
C++
/*
|
|
* Copyright (c) 2021, Gunnar Beutner <gunnar@beutner.name>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <assert.h>
|
|
#include <link.h>
|
|
|
|
using DlIteratePhdrCallbackFunction = int (*)(struct dl_phdr_info*, size_t, void*);
|
|
[[gnu::weak]] extern int __dl_iterate_phdr(DlIteratePhdrCallbackFunction, void*) asm("__dl_iterate_phdr");
|
|
|
|
extern "C" int dl_iterate_phdr(int (*callback)(struct dl_phdr_info* info, size_t size, void* data), void* data)
|
|
{
|
|
return __dl_iterate_phdr(callback, data);
|
|
}
|