In case of shared builds the symbol can be represented in multiple
shared objects, and so if one SO contains _end symbol firstly, then it
it's address can subtracted from the symbol from another SO, and this
give overflow.
Here is an example of such symbol:
$ llvm-readelf -a programs/server/libclickhouse-server-libd.so | fgrep schemata_sql
552: 000000000010b869 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_size
1271: 000000000010b869 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_end
3627: 000000000010b480 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_start
5822: 000000000010b869 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_end
5828: 000000000010b869 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_size
5831: 000000000010b480 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_start
$ llvm-readelf -W -a src/TableFunctions/libclickhouse_table_functionsd.* | fgrep schemata_sql
1709: 00000000001fc5a1 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_end
5107: 00000000001fc5a1 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_size
6090: 00000000001fc1b8 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_start
10975: 00000000001fc1b8 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_start
10976: 00000000001fc5a1 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_end
10977: 00000000001fc5a1 0 NOTYPE GLOBAL DEFAULT 22 _binary_schemata_sql_size
To address this, add base address of the Elf into the resources to
compare with.
Follow-up for: #33134 (cc @alexey-milovidov)
If the order of <common/defines.h> and c++ header will be wrong the
compilation will be broken.
v2: rename __ch_has_feature to ch_has_feature to fix -Wreserved-id-macro
v3: do not fallback to 0