深入理解计算机操作系统第七章家庭作业

2019-07-22  本文已影响0人  Leonzai

7.6

in .symtab? type module section
buf Yes external m .data
bufp0 Yes global swap .data
bufp1 Yes local swap .bss
swap Yes global swap .text
temp No ------ ----- ------
incr Yes local swap .text
count Yes local swap .bss

7.7

删除行 x = -0.0;
或者
int x 改成 double x

7.8

A.
main.1
main.2

B.
unknown
unknown

C.
error
error

7.9

0xe5894855 is 函数main的前2个指令内容。

7.10

A.
gcc p.o libx.a

B.
gcc p.o libx.a liby.a libx.a

C.
gcc p.o libx.a liby.a libx.a libz.a

7.11

.bss 的空间

7.12

A.
ADDR(s) = ADDR(.text) = 0x4004e0
ADDR(r.symbol) = ADDR(swap) = 0x4004f8
refaddr = ADDR(s) + r.offset = 0x4004ea
*refptr = (unsigned) (ADDR(r.symbol) + r.addend - refaddr) = 0xa

B.
ADDR(s) = ADDR(.text) = 0x4004d0
ADDR(r.symbol) = ADDR(swap) = 0x400500
refaddr = ADDR(s) + r.offset = 0x4004da
*refptr = (unsigned) (ADDR(r.symbol) + r.addend - refaddr) = 0x22

7.13

7.13

A.

libm.a path

whereis libm.a

output:

libm: /usr/lib64/libm.a /usr/lib64/libm.so

libm.a files

ar t /usr/lib64/libm.a

output:

s_lib_version.o
s_matherr.o
s_signgam.o
fclrexcpt.o
fgetexcptflg.o
fraiseexcpt.o
fsetexcptflg.o
ftestexcept.o
fegetround.o
fesetround.o
fegetenv.o
feholdexcpt.o
fesetenv.o
feupdateenv.o
t_exp.o
fedisblxcpt.o
feenablxcpt.o
fegetexcept.o
powl_helper.o
e_acos.o
e_acosh.o
e_asin.o
e_atan2.o
e_atanh.o
....

similar way for libc.a

B.

compile code with -Og and -Og -g

不一样

C.

ldd /usr/bin/gcc

    linux-vdso.so.1 =>  (0x00007ffe99d2f000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fc91fb6a000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fc91f7a7000)
    /lib64/ld-linux-x86-64.so.2 (0x00005646f33c1000)
上一篇下一篇

猜你喜欢

热点阅读