導航:首頁 > 操作系統 > linuxlds

linuxlds

發布時間:2022-09-07 04:34:43

⑴ vmlinux.lds.s怎麼被編譯成vmlinux.lds

vmlinux.lds.S用於對ld的輸出進行組版,這個文件的格式在ld.info手冊中有詳細的說明。vmlinu

x.lds.S的主要目的是對輸出文件中段進行排序,並定義相關的符號名,以下是簡要注釋。

/* ld script to make i386 Linux kernel

* Written by Martin Mares ;

*/

OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")

OUTPUT_ARCH(i386) /* 輸出格式 */

ENTRY(_start) /* 定義_start作為入口點 */

SECTIONS

{

. = PAGE_OFFSET_RAW + 0x100000; /* 定義當前段的偏移量(.代表當前計數器) */

_text = .; /* 定義符號_text為當前位置 */

.text : { /* 定義段.text (": {"是段定義符)*/

*(.text) /* 將所有輸入文件中.text段合並到這里 */

*(.fixup) /* 將所有輸入文件中的.fixup段合並到這里 */

*(.gnu.warning) /* 將所有輸入文件中的.gnu.warning段合並到這里 */

} = 0x9090 /* 合並中的空隙用0x9090填充 */

/* 以下的語法含義可以類推 */

.text.lock : { *(.text.lock) } /* out-of-line lock text */

.rodata : { *(.rodata) }

.kstrtab : { *(.kstrtab) }

. = ALIGN(16); /* Exception table */

__start___ex_table = .; /* 定義__start_ex_table符號為當前位置 */

__ex_table : { *(__ex_table) }

__stop___ex_table = .;

__start___ksymtab = .; /* Kernel symbol table */

__ksymtab : { *(__ksymtab) }

__stop___ksymtab = .;

_etext = .; /* End of text section */

.data : { /* Data */

*(.data)

CONSTRUCTORS /* 將C++的構造函數指針段合並到這里 */

}

_edata = .; /* End of data section */

. = ALIGN(8192); /* init_task */

.data.init_task : { *(.data.init_task) }

. = ALIGN(4096); /* Init code and data */

__init_begin = .;

.text.init : { *(.text.init) }

.data.init : { *(.data.init) }

. = ALIGN(4096); /* 輸出計數器在頁邊界上對齊 */

__init_end = .;

. = ALIGN(32);

.data.cacheline_aligned : { *(.data.cacheline_aligned) }

. = ALIGN(4096);

.data.page_aligned : { *(.data.idt) }

__bss_start = .; /* BSS */

.bss : {

*(.bss)

}

_end = . ;

/* Stabs debugging sections. */

.stab 0 : { *(.stab) } /* 0 是段屬性,代表段的起始地址 */

.stabstr 0 : { *(.stabstr) }

.stab.excl 0 : { *(.stab.excl) }

.stab.exclstr 0 : { *(.stab.exclstr) }

.stab.index 0 : { *(.stab.index) }

.stab.indexstr 0 : { *(.stab.indexstr) }

.comment 0 : { *(.comment) }

}

⑵ Linux環境變數順序

內核啟動的時候,各個驅動初始化的工作在文件init/main.c中的do_basic_setup()函數中做.
------------------------------------------------------------------------------------------------------
static void __init do_basic_setup(void)
{
/* drivers will send hotplug events */
init_workqueues();
usermodehelper_init();
driver_init();

#ifdef CONFIG_SYSCTL
sysctl_init();
#endif

/* Networking initialization needs a process context */
sock_init();

do_initcalls();
}
------------------------------------------------------------------------------------------------------
其中的driver_init()做一些核心的初始化,看看代碼就明白了.
相應的驅動程序的初始化在do_initcalls()中做.
------------------------------------------------------------------------------------------------------
static void __init do_initcalls(void)
{
initcall_t *call;
int count = preempt_count();

for (call = __initcall_start; call < __initcall_end; call++) {
char *msg;

if (initcall_debug) {
printk(KERN_DEBUG "Calling initcall 0x%p", *call);
print_fn_descriptor_symbol(": %s()", (unsigned long) *call);
printk("\n");
}

(*call)();

msg = NULL;
if (preempt_count() != count) {
msg = "preemption imbalance";
preempt_count() = count;
}
if (irqs_disabled()) {
msg = "disabled interrupts";
local_irq_enable();
}
if (msg) {
printk(KERN_WARNING "error in initcall at 0x%p: "
"returned with %s\n", *call, msg);
}
}

/* Make sure there is no pending stuff from the initcall sequence */
flush_scheled_work();
}
------------------------------------------------------------------------------------------------------
這個__initcall_start是在文件 arch/xxx/kernel/vmlinux.lds.S (其中的xxx 是你的體系結構的名稱,例如i386)
這個文件是內核ld的時候使用的.其中定義了各個sectioin,看看就明白了。
在這個文件中有個.initcall.init, 代碼如下:
------------------------------------------------------------------------------------------------------
__initcall_start = .;
.initcall.init : {
*(.initcall1.init)
*(.initcall2.init)
*(.initcall3.init)
*(.initcall4.init)
*(.initcall5.init)
*(.initcall6.init)
*(.initcall7.init)
}
------------------------------------------------------------------------------------------------------

這里有7個初始化的優先順序,內核會按照這個優先順序的順序依次載入.
這些優先順序是在文件include/linux/init.h 中定義的. 你注意一下宏 __define_initcall的實現就明白了.
相關代碼如下:

#define __define_initcall(level,fn) \
static initcall_t __initcall_##fn __attribute_used__ \
__attribute__((__section__(".initcall" level ".init"))) = fn

#define core_initcall(fn) __define_initcall("1",fn)
#define postcore_initcall(fn) __define_initcall("2",fn)
#define arch_initcall(fn) __define_initcall("3",fn)
#define subsys_initcall(fn) __define_initcall("4",fn)
#define fs_initcall(fn) __define_initcall("5",fn)
#define device_initcall(fn) __define_initcall("6",fn)
#define late_initcall(fn) __define_initcall("7",fn)

我們可以看到,我們經常寫的設備驅動程序中常用的mole_init其實就是對應了優先順序6:
#define __initcall(fn) device_initcall(fn)

#define mole_init(x) __initcall(x);

文章出處:http://www.diybl.com/course/6_system/linux/Linuxjs/2008628/128990.html
請採納。

⑶ linux 下的lds鏈接腳本有沒有什麼書籍

Linux下有兩個清屏命令: clear 這個命令將會刷新屏幕,本質上只是讓終端顯示頁向後翻了一頁,如果向上滾動屏幕還可以看到之前的操作信息。一般都會使用這個命令。 reset 這個命令將完全刷新終端屏幕,之前的終端輸入操作信息將都會被清空,這樣雖然比較清爽,但整個命令過程速度有點慢,使用較少。

⑷ linux lds 腳本是直接生成嗎

Linux中,周期執行的任務一般由cron這個守護進程來處理ps-ef|grepcroncron讀取一個或多個配置文件,這些配置文件中包含了命令行及其調用時間。cron的配置文件稱為「crontab」,是「crontable」的簡寫。一、cron在3個地方查找配置文件(設置shell腳本):1、/var/spool/cron/yanggang這個目錄下存放的是每個用戶(包括root)的crontab任務,每個任務以創建者的名字命名,比如用戶tom建的crontab任務對應的文件就是/var/spool/cron/tomyanggang@barry$sudols-l/var/spool/cron/(或有時是/var/spool/cron/crontabs/)-rw-------1rootcrontab10712011-09-1917:20root-rw-------1yanggangcrontab11762011-09-2411:07yanggang一般一個用戶最多隻有一個crontab文件(如:root,yanggang等),其對應日誌在/var/spool/mail/root(或/var/spool/mail/yanggang)文件里2、/etc/crontab這個文件負責安排由系統管理員制定的維護系統以及其他任務的crontab。SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/#.----------------minute(0-59)#|.-------------hour(0-23)#||.----------dayofmonth(1-31)#|||.-------month(1-12)ORjan,feb,mar,apr#||||.----dayofweek(0-6)(Sunday=0or7)OR#sun,mon,tue,wed,thu,fri,sat#|||||#*****commandtobeexecuted例如:*/5****root/usr/libexec/atrunminute:代表一小時內的第幾分,范圍0-59。hour:代表一天中的第幾小時,范圍0-23。mday:代表一個月中的第幾天,范圍1-31。month:代表一年中第幾個月,范圍1-12。wday:代表星期幾,范圍0-7(0及7都是星期天)。who:要使用什麼身份執行該指令,當您使用crontab-e時,不必加此欄位。command:所要執行的指令。3、/etc/cron.d/這個目錄用來存放任何要執行的crontab文件或腳本。二、許可權crontab許可權問題到/var/adm/cron/下一看,文件cron.allow和cron.deny是否存在用法如下:1、如果兩個文件都不存在,則只有root用戶才能使用crontab命令。2、如果cron.allow存在但cron.deny不存在,則只有列在cron.allow文件里的用戶才能使用crontab命令,如果root用戶也不在裡面,則root用戶也不能使用crontab。3、如果cron.allow不存在,cron.deny存在,則只有列在cron.deny文件裡面的用戶不能使用crontab命令,其它用戶都能使用。4、如果兩個文件都存在,則列在cron.allow文件中而且沒有列在cron.deny中的用戶可以使用crontab,如果兩個文件中都有同一個用戶,以cron.allow文件裡面是否有該用戶為准,如果cron.allow中有該用戶,則可以使用crontab命令。AIX中普通用戶默認都有crontab許可權,如果要限制用戶使用crontab,就需要編輯/var/adm/cron/cron.denyHP-UNIX中默認普通用戶沒得crontab許可權,要想放開普通用戶的crontab許可權可以編三、創建cron腳本第一步:寫cron腳本文件,命名為crontest.cron。15,30,45,59****echo"xgmtest..">>xgmtest.txt表示,每隔15分鍾,執行列印一次命令第二步:添加定時任務。執行命令「crontabcrontest.cron」。搞定第三步:"crontab-l"查看定時任務是否成功或者檢測/var/spool/cron下是否生成對應cron腳本四、cron服務cron是一個linux下的定時執行工具,可以在無需人工干預的情況下運行作業。/sbin/servicecrondstart//啟動服務/sbin/servicecrondstop//關閉服務/sbin/servicecrondrestart//重啟服務/sbin/servicecrondreload//重新載入配置/sbin/servicecrondstatus//查看服務狀態例如:使用sudo停止與啟動服務yanggang@barry$sudoservicecronstopcronstop/waitingyanggang@barry$sudoservicecronstartcronstart/running,process7502五、crontab用法crontab命令用於安裝、刪除或者列出用於驅動cron後台進程的表格,用戶把需要執行的命令序列放到crontab文件中以獲得執行。每個用戶都可以有自己的crontab文件,/var/spool/cron下的crontab文件不可以直接創建或者直接修改,該crontab文件是通過crontab-e命令創建的在crontab文件中如何輸入需要執行的命令和時間,該文件中每行都包括六個域,其中前五個域是指定命令被執行的時間,最後一個域是要被執行的命令。每個域之間使用空格或者製表符分隔。格式如下:minutehourday-of-monthmonth-of-yearday-of-weekcommands合法值00-5900-2301-3101-120-6(0issunday)除了數字還有幾個個特殊的符號就是"*"、"/"與"-"、",",*代表所有的取值范圍內的數字"/"代表每的意思,"/5"表示每5個單位,"-"代表從某個數字到某個數字,","分開幾個離散的數字。-l在標准輸出上顯示當前的crontab。-r刪除當前的crontab文件。-e使用VISUAL或者EDITOR環境變數所指的編輯器編輯當前的crontab文件。當結束編輯離開時,編輯後的文件將自動安裝。幾個例子:每天早上6點06***echo"Goodmorning.">>/tmp/test.txt//注意單純echo,從屏幕上看不到任何輸出,因為cron把任何輸出都email到root的信箱了。每兩個小時0*/2***echo"Haveabreaknow.">>/tmp/test.txt晚上11點到早上8點之間每兩個小時和早上八點023-7/2,8***echo"Haveagooddream">>/tmp/test.txt每個月的4號和每個禮拜的禮拜一到禮拜三的早上11點0114*1-3commandline1月1日早上4點0411*commandlineSHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=root//如果出現錯誤,或者有數據輸出,數據作為郵件發給這個帳號HOME=/每小時(第一分鍾)執行/etc/cron.hourly內的腳本01****rootrun-parts/etc/cron.hourly每天(凌晨4:02)執行/etc/cron.daily內的腳本024***rootrun-parts/etc/cron.daily每星期(周日凌晨4:22)執行/etc/cron.weekly內的腳本224**0rootrun-parts/etc/cron.weekly每月(1號凌晨4:42)去執行/etc/cron.monthly內的腳本4241**rootrun-parts/etc/cron.monthly注意:"run-parts"這個參數了,如果去掉這個參數的話,後面就可以寫要運行的某個腳本名,而不是文件夾名。每天的下午4點、5點、6點的5min、15min、25min、35min、45min、55min時執行命令。5,15,25,35,45,5516,17,18***command每周一,三,五的下午3:00系統進入維護狀態,重新啟動系統。0015**1,3,5shutdown-r+5每小時的10分,40分執行用戶目錄下的innd/bbslin這個指令:10,40****innd/bbslink每小時的1分執行用戶目錄下的bin/account這個指令:1****bin/account每天早晨三點二十分執行用戶目錄下如下所示的兩個指令(每個指令以;分隔):203***(/bin/rm-fexpire.lslogins.bad;bin/expire$#@62;expire.1st)每年的一月和四月,4號到9號的3點12分和3點55分執行/bin/rm-fexpire.1st這個指令,並把結果添加在mm.txt這個文件之後(mm.txt文件位於用戶自己的目錄位置)。12,5534-91,4*/bin/rm-fexpire.1st$#@62;$#@62;mm.txt六、幾個問題crond進程沒有運行1.啟動crond進程/etc/init.d/crondstart2.開機自啟動crond進程chkconfigcrondoncrontab編輯:輸入編輯命令:crontab-e#mhdommondowcommandSHELL=/bin/bash30****cd/home/barry/top800/top10/top10_fruits/&&./top10_all.shCtrl+O(寫入)——》enter鍵(保存文件名)——》Ctrl+X(退出)輸入查看命令:crontab-l#mhdommondowcommandSHELL=/bin/bash30****cd/home/barry/top800/top10/top10_fruits/&&./top10_all.sh(建議使用此方式)語法錯誤:Syntaxerror:"("unexpected路徑錯誤:在/var/spool/crontab/yanggang中,添加了如下命令,在日誌文件/var/spool/mail/yanggang中提示找不到xxx.sh路徑30****/home/barry/top800/top10/top10_fruits/top10_all.sh或30****bash/home/barry/top800/top10/top10_fruits/top10_all.sh這是因為在crontab中使用了絕對路徑執行腳本top10_all.sh,因此在腳本top10_all.sh中引用的其它腳本也都需要使用絕對路徑,才能被crontab找到並執行如何避免絕對路徑復雜的設置呢,如上文六、幾個問題所示,採用如下格式:30****cd/home/barry/top800/top10/top10_fruits/&&./top10_all.sh(建議使用此方式,先進入該目錄,然後在執行腳本;否則,執行腳本中的其它腳本都需要加絕對路徑)

⑸ lds是什麼文件

下面是vmlinux.lds.S文件,我老是覺得暈暈的,有哪位大蝦能解釋一下或推薦一個有相關學習資料的站點?
/* ld script to make i386 Linux kernel
* Written by Martin Mares ;
*/
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
. = PAGE_OFFSET_RAW + 0x100000;
_text = .; /* Text and read-only data */
.text : {
*(.text)
*(.fixup)
*(.gnu.warning)
} = 0x9090
.text.lock : { *(.text.lock) } /* out-of-line lock text */
.rodata : { *(.rodata) }
.kstrtab : { *(.kstrtab) }

. = ALIGN(16); /* Exception table */
__start___ex_table = .;
__ex_table : { *(__ex_table) }
__stop___ex_table = .;

__start___ksymtab = .; /* Kernel symbol table */
__ksymtab : { *(__ksymtab) }
__stop___ksymtab = .;

_etext = .; /* End of text section */

.data : { /* Data */
*(.data)
CONSTRUCTORS
}

_edata = .; /* End of data section */

. = ALIGN(8192); /* init_task */
.data.init_task : { *(.data.init_task) }

. = ALIGN(4096); /* Init code and data */
__init_begin = .;
.text.init : { *(.text.init) }
.data.init : { *(.data.init) }
. = ALIGN(4096);
__init_end = .;

. = ALIGN(32);
.data.cacheline_aligned : { *(.data.cacheline_aligned) }

. = ALIGN(4096);
.data.page_aligned : { *(.data.idt) }

__bss_start = .; /* BSS */
.bss : {
*(.bss)
}
_end = . ;

/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
}

⑹ 如何解讀vmlinux.lds.S

vmlinux.lds.S用於對ld的輸出進行組版,這個文件的格式在ld.info手冊中有詳細的說明。vmlinu x.lds.S的主要目的是對輸出文件中段進行排序,並定義相關的符號名,以下是簡要注釋。 /* ld script to make i386 Linux kernel * Written by Martin M...

閱讀全文

與linuxlds相關的資料

熱點內容
php如何解析xml文件 瀏覽:698
如何改變appstore的語言 瀏覽:458
javahtmlxml 瀏覽:26
單片機啟動文件 瀏覽:809
橙app如何開啟聊天 瀏覽:899
訪問伺服器公網地址 瀏覽:666
pdf列印底色去掉 瀏覽:463
java快遞介面 瀏覽:397
哪個app可以教新爸爸 瀏覽:210
如何查看伺服器系統版本信息 瀏覽:524
成都市土地出讓金演算法 瀏覽:702
鋼筋加密標記 瀏覽:577
ps中擴展功能在文件夾的什麼位置 瀏覽:904
雙極壓縮機為什麼要先高壓 瀏覽:527
蘋果手機伺服器填什麼 瀏覽:832
android移動動畫效果 瀏覽:691
電子和伺服器是什麼意思 瀏覽:692
phpurl中文亂碼問題 瀏覽:894
程序員那麼可愛大結局陸漓產子 瀏覽:538
java如何從雲伺服器讀取本地文件 瀏覽:924