super皮波 发表于 2014-12-17 14:33

请教一下vmlinux.lds.S链接脚本

arm体系结构
如下的DISCARD这个段是干嘛用的?
"/DISCARD/"是个段名?为什么两边要加上"/"呢?
多谢
SECTIONS
{
        /*
       * XXX: The linker does not define how output sections are
       * assigned to input sections when there are multiple statements
       * matching the same input section name.There is no documented
       * order of matching.
       *
       * unwind exit sections must be discarded before the rest of the
       * unwind sections get included.
       */
        /DISCARD/ : {
                *(.ARM.exidx.exit.text)
                *(.ARM.extab.exit.text)
                ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
                ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
                ARM_EXIT_DISCARD(EXIT_TEXT)
                ARM_EXIT_DISCARD(EXIT_DATA)
                EXIT_CALL
#ifndef CONFIG_HOTPLUG
                *(.ARM.exidx.devexit.text)
                *(.ARM.extab.devexit.text)
#endif
#ifndef CONFIG_MMU
                *(.fixup)
                *(__ex_table)
#endif
#ifndef CONFIG_SMP_ON_UP
                *(.alt.smp.init)
#endif
                *(.discard)
                *(.discard.*)
        }

arm-linux-gcc 发表于 2014-12-17 16:38

ld.pdf中有写

The special output section name ‘/DISCARD/’ may be used to discard input sections. Any
input sections which are assigned to an output section named ‘/DISCARD/’ are not included
in the output file.

super皮波 发表于 2014-12-17 19:44

回复 2# arm-linux-gcc
多谢
那我直接不把这些section链接进来不就行了嘛,为嘛要特别说明一下?


   

Tinnal 发表于 2014-12-17 21:24

回复 3# super皮波


unwind exit sections must be discarded before the rest of the
         * unwind sections get included.

这句话看来,应该是想法unwind整体信息的exit部分剔除出去。但又不想一个一个的加进来,所以采用了减法。

假设 unwind total = A + B+ C + D
则 include A + include B + include C = include total - exclude C

这样还能防止以后unwind信息出现扩展时必须更改链接脚本的。


   
页: [1]
查看完整版本: 请教一下vmlinux.lds.S链接脚本