Openbsd
OpenBSD 5.9 無法預載入庫 ''
我為 Linux 和 OpenBSD 開發,有時我得到錯誤
can't preload library
- 你知道這意味著什麼嗎?我得到的確切輸出是:
: can't preload library
當我嘗試執行腳本和/或二進製文件時。這似乎與引用有關,但我不確定。
這個問題在 Linux 上不會出現,只有 OpenBSD 才會出現。
程式碼在這裡,但我不知道它的作用:
void _dl_dopreload(char *paths) { char *cp, *dp; elf_object_t *shlib; dp = paths = _dl_strdup(paths); if (dp == NULL) { _dl_printf("preload: out of memory"); _dl_exit(1); } while ((cp = _dl_strsep(&dp, ":")) != NULL) { shlib = _dl_load_shlib(cp, _dl_objects, OBJTYPE_LIB, _dl_objects->obj_flags); if (shlib == NULL) { _dl_printf("%s: can't preload library '%s'\n", __progname, cp); _dl_exit(4); } _dl_add_object(shlib); _dl_link_child(shlib, _dl_objects); } _dl_free(paths); return; }
這是我的腳本,適用於
dash
Linux,我嘗試使用 OpenBSD:s Korn shell 執行它。#!/bin/sh echo "-- Testing our implementation of OpenShell --" echo "" echo "- If you have any problem in passing a test read the corresponding" echo "- source file to understand what the test is checking" echo "" printf "********************* PRESS ENTER TO RUN TESTS ... " read _ # Key pressed, do something printf "********************* TEST WILDCARDS \n***** Press any key to listing all files in current directory...\nYou should see filesnames *.* below " read _ valgrind --leak-check=full -v ./shell << EOF ls -al *.* EOF printf "********************* TEST ALGORITHMS ... \n***** Press any key to run the algorithms... .\nYou should see the output from top -b -n1|head -8|tail -1 " read _ top -b -n1|head -8|tail -1|sort -n|wc -l valgrind --leak-check=full -v ./shell << EOF ls|grep open EOF printf "********************* TEST ALGORITHMS Part II. ... .\nYou should see the output from who|awk '{print \$4 ; print \$3}'|sort -n|wc -l. " read _ valgrind --leak-check=full ./shell << EOF who|awk '{print \$4 ; print \$3}'|sort -n|wc -l EOF printf "********************* TEST CHECKENV. ..... .\nYou should see the output checkenv below " read _ valgrind ./shell << EOF checkenv EOF printf "********************* TEST DONE. YOU SHOULD SEE OUTPUT FROM TEST ABOVE ... " read _
openbsd
在安全性方面有一個獨特的記憶體管理概念。因此,不能預載入靜態連結庫。程式碼如下:
shlib = _dl_load_shlib(cp, _dl_objects, OBJTYPE_LIB, _dl_objects->obj_flags); if (shlib == NULL) { _dl_printf("%s: can't preload library '%s'\n", __progname, cp); _dl_exit(4); }
因此,
shlib
不應將 的值測試為NULL
。請嘗試載入動態連結庫,這應該可以。