{"id":383051,"date":"2024-06-29T04:39:33","date_gmt":"2024-06-29T04:39:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=383051"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=383051","title":{"rendered":"<span>\u041f\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 Linux x86, \u0438\u043b\u0438 \u043a\u0430\u043a \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u043e main()?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/588102\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\"\/><\/div>\n<p><\/a><\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0432 Linux. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 ELF x86. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0435\u0449\u0435 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <code>main<\/code>. <a name=\"habracut\"><\/a><\/p>\n<p>  \u0412\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u043a\u043e\u0435-\u043a\u0430\u043a\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432 \u043d\u0435\u043c \u0431\u044b\u043b\u0438 \u043e\u043f\u0443\u0449\u0435\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0446\u0435\u043b\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e\u0442. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u043b\u0438\u043d\u043a\u043e\u0432\u043a\u0443 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u044e\u0430\u043d\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f. \u0412\u0441\u0435 \u044d\u0442\u0438 \u0434\u0435\u0442\u0430\u043b\u0438 \u044f \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0443, \u043d\u043e \u043a \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u043d\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043d\u0430\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\"\/><br \/>  <i><font color=\"#999999\">\u0421\u0445\u0435\u043c\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e dot-\u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0433\u0440\u0430\u0444\u043e\u0432<\/font><\/i><\/p>\n<p>  \u041a \u043a\u043e\u043d\u0446\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0430\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e.<\/p>\n<h3><font color=\"#3AC1EF\">\u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 main?<\/font><\/h3>\n<p>  \u041c\u044b \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0421\u0438 \u0441 \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439<code>main<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0435 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u0412 \u0445\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u043d\u043a\u0443\u0435\u043c\u0430\u044f \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>_start<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e <code>main<\/code>.<\/p>\n<pre><code class=\"bash\">int main() { }<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043f\u0438\u044e \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043a\u0430\u043a <code>prog1.c<\/code> \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0437\u0430 \u043c\u043d\u043e\u0439. \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044e \u0435\u0435 \u0441\u0431\u043e\u0440\u043a\u0443:<\/p>\n<pre><code class=\"bash\">gcc -ggdb -o prog1 prog1.c<\/code><\/pre>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (<code>prog2<\/code>) \u0432 <code>gdb<\/code>, \u043c\u044b \u0435\u0435 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u0443\u0437\u043d\u0430\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u042f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u0432\u044b\u0432\u043e\u0434 <code>objdump -d prog1<\/code>, \u043d\u043e \u043d\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430, \u0430 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. (\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0432\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0430\u043c\u0438\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043f\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>objdump -d prog1 >prog1.dump<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0435 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435). <\/p>\n<h3><font color=\"#3AC1EF\">\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f, \u043a\u0430\u043a \u043c\u044b \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 _start<\/font><\/h3>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u0438\u043b\u0438 GUI \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 <code>execve()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>execve()<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0435 <code>man execve<\/code>. \u041e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 2 \u043c\u0430\u043d\u0443\u0430\u043b\u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u043e\u043d \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0435\u043a \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0432 \u043d\u0435\u0433\u043e <code>argc<\/code>, <code>argv<\/code> \u0438 <code>envp<\/code>. <\/p>\n<p>  \u0414\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u0444\u0430\u0439\u043b\u043e\u0432 <code>0<\/code>, <code>1<\/code> \u0438 <code>2<\/code> (<code>stdin<\/code>, <code>stdout<\/code>, <code>stderr<\/code>) \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043d\u0438\u0445 \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u043e\u0439. \u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044f \u0440\u0435\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0438, \u043a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u043e\u0437\u0434\u043d\u0435\u0435, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043f\u0440\u0435-\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b. \u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 <code>_start()<\/code>.<\/p>\n<p>  \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u0434\u0435\u043b <code>objdump -d prog1<\/code>:<\/p>\n<pre><code class=\"bash\">080482e0 &lt;_start>: 80482e0:       31 ed                   xor    %ebp,%ebp 80482e2:       5e                      pop    %esi 80482e3:       89 e1                   mov    %esp,%ecx 80482e5:       83 e4 f0                and    $0xfffffff0,%esp 80482e8:       50                      push   %eax 80482e9:       54                      push   %esp 80482ea:       52                      push   %edx 80482eb:       68 00 84 04 08          push   $0x8048400 80482f0:       68 a0 83 04 08          push   $0x80483a0 80482f5:       51                      push   %ecx 80482f6:       56                      push   %esi 80482f7:       68 94 83 04 08          push   $0x8048394 80482fc:       e8 c3 ff ff ff          call   80482c4 &lt;__libc_start_main@plt> 8048301:       f4                      hlt<\/code><\/pre>\n<p>  \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f XOR \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0441\u0430\u043c\u0438\u043c \u0441\u043e\u0431\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 \u043d\u0443\u043b\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <code>xor %ebp,%ebp<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 <code>%ebp<\/code> \u043d\u0430 \u043d\u0443\u043b\u044c. \u042d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 ABI (Application Binary Interface) \u0434\u043b\u044f \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0430.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0435\u043a\u0430. \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 <code>argc<\/code>, <code>argv <\/code>\u0438 <code>envp<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 <code>argc <\/code>\u0432 <code>%esi<\/code>. \u041c\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u0441\u043a\u043e\u0440\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0441\u0442\u0435\u043a. \u0422\u0430\u043a \u043a\u0430\u043a <code>argc <\/code>\u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u043b\u0438, <code>%esp<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 <code>argv<\/code>. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f <code>mov <\/code>\u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 <code>argv <\/code>\u0432 <code>%ecx<\/code>, \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u0442\u0435\u043a\u0430. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0441\u0442\u0435\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e <code>and <\/code>\u0441 \u043c\u0430\u0441\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u0442 \u043d\u0438\u0436\u043d\u0438\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0438\u0442\u0430. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u043e\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u0441\u044f \u043d\u0438\u0436\u0435 \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u043e\u0442 0 \u0434\u043e 15 \u0431\u0430\u0439\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044e \u043a\u0440\u0430\u0442\u043d\u043e 16 \u0431\u0430\u0439\u0442\u0430\u043c. \u0417\u0430 \u0441\u0447\u0435\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0435\u043a\u0430 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043a\u044d\u0448\u0430. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f SSE (Streaming SIMD Extensions), \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>%esp<\/code> \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0432 <code>_start<\/code> \u0438\u043c\u0435\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>0xbffff770<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u043b\u0438 <code>argc<\/code>, <code>%esp<\/code> \u0441\u0442\u0430\u043b <code>0xbffff774<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043c\u0435\u0441\u0442\u0438\u043b\u0441\u044f \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0430\u0434\u0440\u0435\u0441 (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u0442\u0435\u043a \u0432\u0435\u0434\u0435\u0442 \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u043d\u0438\u0437, \u0430 \u0438\u0445 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u2013 \u0432\u0432\u0435\u0440\u0445). \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f <code>and <\/code>\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0441\u0442\u0435\u043a\u0430 \u0432\u043d\u043e\u0432\u044c \u0441\u0442\u0430\u043b\u043e <code>0xbffff770<\/code>.<\/p>\n<h3><font color=\"#3AC1EF\">\u0414\u0430\u043b\u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 __libc_start_main<\/font><\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0441\u0442\u0435\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f <code>_libc_start_main<\/code>. \u041f\u0435\u0440\u0432\u044b\u0439, <code>%eax<\/code>, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0443\u0441\u043e\u0440\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0432 \u0441\u0442\u0435\u043a \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c 7 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0434\u043b\u044f 16-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f 8-\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0421\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>_libc_start_main<\/code> \u043b\u0438\u043d\u043a\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <code>glibc<\/code>. \u0412 \u0434\u0435\u0440\u0435\u0432\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <code>glibc <\/code>\u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>csu\/libc-start.c<\/code>. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f <code>_libc_start_main<\/code> \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">int __libc_start_main(  int (*main) (int, char * *, char * *),     int argc, char * * ubp_av,     void (*init) (void),     void (*fini) (void),     void (*rtld_fini) (void),     void (* stack_end));<\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u0447\u0442\u043e <code>_start<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u0442\u0435\u043a \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 <code>_libc_start_main<\/code>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ed\/cx\/xw\/edcxxwcenwjav8m5oklyfgtzeuq.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ed\/cx\/xw\/edcxxwcenwjav8m5oklyfgtzeuq.png\"\/><\/div>\n<p><i><font color=\"#999999\">\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0435\u043a\u0430 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>__libc_start_main<\/code><\/font><\/i><\/p>\n<p>  <code>__libc_csu_fini<\/code> \u043b\u0438\u043d\u043a\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448 \u043a\u043e\u0434 \u0438\u0437 <code>glibc <\/code>\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <code>csu\/elf-init.c<\/code> \u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u042d\u0442\u043e \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0421\u0438, \u0438 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u044f \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0435\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. <\/p>\n<h2><font color=\"#3AC1EF\">\u0422\u0430\u043a, \u0430 \u0433\u0434\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b?<\/font><\/h2>\n<p>  <\/p>\n<pre><code class=\"bash\">void __libc_init_first(int argc, char *arg0, ...) {     char **argv = &amp;arg0, **envp = &amp;argv[argc + 1];     __environ = envp;     __libc_init (argc, argv, envp); }<\/code><\/pre>\n<p>  \u0412\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 <code>envp<\/code>, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u0430\u0448\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b? \u0421\u0440\u0435\u0434\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 <code>_libc_start_main<\/code> \u0435\u0433\u043e \u0442\u043e\u0436\u0435 \u043d\u0435\u0442. \u041d\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e <code>main <\/code>\u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>int main(int argc, char** argv, char** envp)<\/code>, \u0442\u0430\u043a \u0432 \u0447\u0435\u043c \u0436\u0435 \u0434\u0435\u043b\u043e?<\/p>\n<p>  \u0427\u0442\u043e \u0436, <code>_libc_start_main<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>_libc_init_first<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u0433\u043e \u043d\u0443\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>_environ<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e <code>_libc_start_main<\/code> \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 <code>main<\/code>. <\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 <code>envp <\/code>\u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>_libc_start_main<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0440\u044e\u043a \u0438\u2026\u0432\u0443\u0430\u043b\u044f! \u0421\u0440\u0430\u0437\u0443 \u0437\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u043c \u043d\u0443\u043b\u0435\u043c \u0432 \u043a\u043e\u043d\u0446\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>envp <\/code>\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 ELF, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u044b <code>LD_SHOW_AUXV=1<\/code>. \u0412\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 <code>prog1<\/code>:<\/p>\n<pre><code class=\"bash\">$ LD_SHOW_AUXV=1 .\/prog1 AT_SYSINFO:      0xe62414 AT_SYSINFO_EHDR: 0xe62000 AT_HWCAP:    fpu vme de pse tsc msr pae mce cx8 apic              mtrr pge mca cmov pat pse36 clflush dts              acpi mmx fxsr sse sse2 ss ht tm pbe AT_PAGESZ:       4096 AT_CLKTCK:       100 AT_PHDR:         0x8048034 AT_PHENT:        32 AT_PHNUM:        8 AT_BASE:         0x686000 AT_FLAGS:        0x0 AT_ENTRY:        0x80482e0 AT_UID:          1002 AT_EUID:         1002 AT_GID:          1000 AT_EGID:         1000 AT_SECURE:       0 AT_RANDOM:       0xbff09acb AT_EXECFN:       .\/prog1 AT_PLATFORM:     i686<\/code><\/pre>\n<p>  \u0420\u0430\u0437\u0432\u0435 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0422\u0443\u0442 \u043f\u043e\u043b\u043d\u043e \u0432\u0441\u044f\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. <\/p>\n<ul>\n<li>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c <code>AT_ENTRY<\/code>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0430\u0434\u0440\u0435\u0441 <code>_start<\/code>, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0448 <code>userid<\/code>, \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <code>userid <\/code>\u0438 <code>groupid<\/code>. <\/li>\n<li>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 <code>686<\/code>, \u0430 \u0447\u0430\u0441\u0442\u043e\u0442\u0430 <code>times()<\/code> \u0440\u0430\u0432\u043d\u0430 <code>100<\/code> \u0442\u0430\u043a\u0442\u043e\u0432\/\u0441. <\/li>\n<li><code>AT_PHDR<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 ELF-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0445 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e \u0437\u0430\u043f\u0438\u0441\u044f\u0445 \u0440\u0435\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u0438 \u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0443. <\/li>\n<li><code>AT_PHENT<\/code> \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430.<\/li>\n<\/ul>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<h3><font color=\"#3AC1EF\">__libc_start_main \u0432 \u043e\u0431\u0449\u0435\u043c<\/font><\/h3>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044f \u0437\u0430\u043a\u043e\u043d\u0447\u0443 \u0440\u0430\u0437\u0431\u043e\u0440 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 <code>_libc_start_main<\/code> \u0438 \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e \u0432 \u043e\u0431\u0449\u0435\u043c \u043e\u043d:<\/p>\n<ul>\n<li>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432<code>setuid <\/code>\u0438 <code>stgid<\/code>;<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443;<\/li>\n<li>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>fini <\/code>(\u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b) \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>rtld_fini<\/code> (\u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430 \u0441\u0440\u0435\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 <code>at_exit<\/code> \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430.<\/li>\n<li>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>init<\/code>;<\/li>\n<li>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>main <\/code>\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u043c\u0438 \u0435\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 <code>argc <\/code>\u0438 <code>argv<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c <code>global_environ<\/code>, \u043e \u0447\u0435\u043c \u044f \u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0448\u0435;<\/li>\n<li>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>exit <\/code>\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c <code>main<\/code> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u0412\u044b\u0437\u043e\u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 init<\/font><\/h3>\n<p>  \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>init <\/code>\u0434\u043b\u044f <code>_libc_start_main<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <code>_libc_csu_init<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u043b\u0438\u043d\u043a\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448 \u043a\u043e\u0434. \u041e\u043d \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0421\u0438, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>csu\/elf-init.c<\/code> \u0434\u0435\u0440\u0435\u0432\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <code>glibc<\/code>, \u0438 \u043b\u0438\u043d\u043a\u0443\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0415\u0433\u043e \u043a\u043e\u0434 \u0421\u0438 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 (\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 <code>#ifdef<\/code>)\u2026<\/p>\n<h2><font color=\"#3AC1EF\">\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/font><\/h2>\n<p>  <\/p>\n<pre><code class=\"bash\">void __libc_csu_init (int argc, char **argv, char **envp) {    _init ();    const size_t size = __init_array_end - __init_array_start;   for (size_t i = 0; i &lt; size; i++)       (*__init_array_start [i]) (argc, argv, envp); }<\/code><\/pre>\n<p>  <code>_libc_csu_init<\/code> \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u0435\u043d, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u0442 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b. \u042f \u0443\u0436\u0435 \u0441\u043b\u044b\u0448\u0443, \u043a\u0430\u043a \u0432\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435: \u00ab\u042d\u0442\u043e \u0436\u0435 \u043d\u0435 C++!\u00bb. \u0412\u0441\u0435 \u0432\u0435\u0440\u043d\u043e, \u043d\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u043d\u0435 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043a C++ \u0438 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u044d\u0442\u043e\u043c\u0443 \u044f\u0437\u044b\u043a\u0443. <\/p>\n<p>  \u041d\u0430\u0448 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0421\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>_libc_csu_init<\/code> \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>_libc_csu_fini<\/code>. \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043a\u0430\u043a \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0434\u0430\u043b\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0449\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0443\u0440\u043e\u0432\u043d\u044f \u0421\u0438 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043b\u044e\u0431\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0439\u0434\u0435\u0442. \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0421\u0438 \u043e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0438 \u0432 \u0445\u043e\u0434\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u044d\u0442\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e. \u0425\u043e\u0442\u044f, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u043e\u0431\u043d\u0435\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0438 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b. \u0412\u043e\u0442 \u043a\u043e\u0434 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f <code>_libc_csu_init<\/code>:<\/p>\n<pre><code class=\"bash\">080483a0 &lt;__libc_csu_init>:  80483a0:       55                      push   %ebp  80483a1:       89 e5                   mov    %esp,%ebp  80483a3:       57                      push   %edi  80483a4:       56                      push   %esi  80483a5:       53                      push   %ebx  80483a6:       e8 5a 00 00 00          call   8048405 &lt;__i686.get_pc_thunk.bx>  80483ab:       81 c3 49 1c 00 00       add    $0x1c49,%ebx  80483b1:       83 ec 1c                sub    $0x1c,%esp  80483b4:       e8 bb fe ff ff          call   8048274 &lt;_init>  80483b9:       8d bb 20 ff ff ff       lea    -0xe0(%ebx),%edi  80483bf:       8d 83 20 ff ff ff       lea    -0xe0(%ebx),%eax  80483c5:       29 c7                   sub    %eax,%edi  80483c7:       c1 ff 02                sar    $0x2,%edi  80483ca:       85 ff                   test   %edi,%edi  80483cc:       74 24                   je     80483f2 &lt;__libc_csu_init+0x52>  80483ce:       31 f6                   xor    %esi,%esi  80483d0:       8b 45 10                mov    0x10(%ebp),%eax  80483d3:       89 44 24 08             mov    %eax,0x8(%esp)  80483d7:       8b 45 0c                mov    0xc(%ebp),%eax  80483da:       89 44 24 04             mov    %eax,0x4(%esp)  80483de:       8b 45 08                mov    0x8(%ebp),%eax  80483e1:       89 04 24                mov    %eax,(%esp)  80483e4:       ff 94 b3 20 ff ff ff    call   *-0xe0(%ebx,%esi,4)  80483eb:       83 c6 01                add    $0x1,%esi  80483ee:       39 fe                   cmp    %edi,%esi  80483f0:       72 de                   jb     80483d0 &lt;__libc_csu_init+0x30>  80483f2:       83 c4 1c                add    $0x1c,%esp  80483f5:       5b                      pop    %ebx  80483f6:       5e                      pop    %esi  80483f7:       5f                      pop    %edi  80483f8:       5d                      pop    %ebp  80483f9:       c3                      ret<\/code><\/pre>\n<h3><font color=\"#3AC1EF\">\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 thunk?<\/font><\/h3>\n<p>  \u0413\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u043e \u0447\u0435\u043c, \u043d\u043e \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u044d\u0442\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>get_pc_thunk<\/code> \u0432\u0435\u0441\u044c\u043c\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430. \u041e\u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u043e-\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0430\u0434\u0440\u0435\u0441 <code>GLOBAL_OFFSET_TABLE<\/code>. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">__get_pc_thunk_bx: movel (%esp),%ebx return<\/code><\/pre>\n<pre><code class=\"bash\">push %ebx call __get_pc_thunk_bx add  $_GLOBAL_OFFSET_TABLE_,%ebx<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435. \u0412\u044b\u0437\u043e\u0432 <code>_get_pc_thunk_bx<\/code>, \u043a\u0430\u043a \u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439, \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u0441\u0442\u0435\u043a \u0430\u0434\u0440\u0435\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b\u043e\u0441\u044c \u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. \u0417\u043d\u0430\u0447\u0438\u0442, \u0432 <code>_get_pc_thunk_bx<\/code> \u043c\u044b \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0430\u0434\u0440\u0435\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0432 <code>%ebx<\/code>. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0442, \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u043d\u0435\u043c\u0443 <code>_GLOBAL_OFFSET_TABLE_<\/code>, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044f\u0441\u044c \u0432 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u043e-\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043a\u043e\u0434\u043e\u043c. <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f, \u0438 \u043d\u0430\u043c \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u0438\u0445 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0441\u0430\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0434\u043b\u044f \u043d\u0430\u0441 \u043d\u0443\u0436\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441. \u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430. \u0411\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0438\u0441\u0442\u0438\u043d\u0435 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0421\u0438\/\u0421++ \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>-pic<\/code> \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438.<br \/>  \u0412\u0441\u0442\u0440\u0435\u0447\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u0431\u044b\u043b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>-pic<\/code>. <\/p>\n<h3><font color=\"#3AC1EF\">\u041d\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0446\u0438\u043a\u043b?<\/font><\/h3>\n<p>  \u0426\u0438\u043a\u043b \u0438\u0437 <code>_libc_csu_init<\/code> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>init()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>_init<\/code>. \u041f\u043e\u043a\u0430 \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432\u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043b\u044e\u0431\u044b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u044b \u0443\u0440\u043e\u0432\u043d\u044f \u0421\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u0412\u044b\u0437\u043e\u0432 _init<\/font><\/h3>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e. \u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 <code>_start<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u0432\u0430\u043b\u0430 <code>_libc_start_main<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u0432\u0430\u043b\u0430 <code>_libc_csu_init<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>_init<\/code>:<\/p>\n<pre><code class=\"bash\">08048274 &lt;_init>:  8048274:       55                      push   %ebp  8048275:       89 e5                   mov    %esp,%ebp  8048277:       53                      push   %ebx  8048278:       83 ec 04                sub    $0x4,%esp  804827b:       e8 00 00 00 00          call   8048280 &lt;_init+0xc>  8048280:       5b                      pop    %ebx  8048281:       81 c3 74 1d 00 00       add    $0x1d74,%ebx        (.got.plt)  8048287:       8b 93 fc ff ff ff       mov    -0x4(%ebx),%edx  804828d:       85 d2                   test   %edx,%edx  804828f:       74 05                   je     8048296 &lt;_init+0x22>  8048291:       e8 1e 00 00 00          call   80482b4 &lt;__gmon_start__@plt>  8048296:       e8 d5 00 00 00          call   8048370 &lt;frame_dummy>  804829b:       e8 70 01 00 00          call   8048410 &lt;__do_global_ctors_aux>  80482a0:       58                      pop    %eax  80482a1:       5b                      pop    %ebx  80482a2:       c9                      leave  80482a3:       c3                      ret<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043e \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u0421\u0438<\/font><\/h3>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0438, \u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 <a href=\"http:\/\/dbp-consulting.com\/tutorials\/debugging\/basicAsmDebuggingGDB.html\">Basic Assembler Debugging with GDB<\/a>. \u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432 \u0441\u0442\u0435\u043a\u0435 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0431\u0430\u0437\u044b \u043d\u0430 \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0443 \u0441\u0442\u0435\u043a\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 4-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0437\u0434\u0435\u0441\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u0443 <code>get_pc_thunk<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0442\u043e \u043e\u043d \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443 \u0430\u0434\u0440\u0435\u0441\u0443. \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442 \u043d\u0430\u0441 \u043a \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b\u0438, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0431\u043e\u0447\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0435\u043a\u0435. \u041e\u043d \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 <code>%ebx<\/code>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<h3><font color=\"#3AC1EF\">\u041f\u043e\u043a\u0430\u0436\u0438 \u043c\u043d\u0435 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0444\u0438\u043b\u044c<\/font><\/h3>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 <code>gmon_start<\/code>. \u0415\u0441\u043b\u0438 \u043e\u043d \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u043c\u044b \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u0435\u043c. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u043e\u0432 <code>at_exit<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0430 <code>gmon.out<\/code>.<\/p>\n<h3><font color=\"#3AC1EF\">\u0412\u044b\u0437\u043e\u0432 frame_dummy<\/font><\/h3>\n<p>  \u0412 \u043b\u044e\u0431\u043e\u043c \u0438\u0437 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>frame_dummy<\/code>. \u0412\u043e\u043e\u0431\u0449\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>_register_frame_info<\/code>, \u0430 <code>frame_dummy<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u041a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2013 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u043e\u0432\u044b\u0445 \u0444\u0440\u0435\u0439\u043c\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439. \u042d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f, \u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<h3><font color=\"#3AC1EF\">\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u043c!<\/font><\/h3>\n<p>  \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>_do_global_ctors_aux<\/code>. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <code>main<\/code>, \u0442\u043e \u0438\u0441\u043a\u0430\u0442\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u044e\u0434\u0430 \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0421++, \u043d\u043e \u043a\u0440\u043e\u043c\u0435 \u043d\u0438\u0445 \u0442\u0443\u0442 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<h3><font color=\"#3AC1EF\">\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440<\/font><\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c <code>prog1<\/code>, \u0441\u043e\u0437\u0434\u0430\u0432 <code>prog2<\/code>. \u0421\u0430\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2013 \u044d\u0442\u043e <code>__attribute__ ((constructor))<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 <code>gcc<\/code>, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e <code>_do_global_ctors_aux<\/code>. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043d\u0430\u0448 \u0444\u0438\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. (\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>_FUNCTION_<\/code> \u0438\u043c\u0435\u043d\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u042d\u0442\u043e \u043c\u0430\u0433\u0438\u044f <code>gcc<\/code>).<\/p>\n<pre><code class=\"bash\">#include &lt;stdio.h>  void __attribute__ ((constructor)) a_constructor() {     printf(\"%s\\n\", __FUNCTION__); }  int main() {     printf(\"%s\\n\",__FUNCTION__); }<\/code><\/pre>\n<pre><code class=\"bash\">$ .\/prog2 a_constructor main $<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">_init \u0432 prog2 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f<\/font><\/h3>\n<p>  \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 <code>gdb <\/code>\u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u044d\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041d\u0443 \u0430 \u043f\u043e\u043a\u0430 \u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0435 <code>_init<\/code>.<\/p>\n<pre><code class=\"bash\">08048290 &lt;_init>:  8048290:       55                      push   %ebp  8048291:       89 e5                   mov    %esp,%ebp  8048293:       53                      push   %ebx  8048294:       83 ec 04                sub    $0x4,%esp  8048297:       e8 00 00 00 00          call   804829c &lt;_init+0xc>  804829c:       5b                      pop    %ebx  804829d:       81 c3 58 1d 00 00       add    $0x1d58,%ebx  80482a3:       8b 93 fc ff ff ff       mov    -0x4(%ebx),%edx  80482a9:       85 d2                   test   %edx,%edx  80482ab:       74 05                   je     80482b2 &lt;_init+0x22>  80482ad:       e8 1e 00 00 00          call   80482d0 &lt;__gmon_start__@plt>  80482b2:       e8 d9 00 00 00          call   8048390 &lt;frame_dummy>  80482b7:       e8 94 01 00 00          call   8048450 &lt;__do_global_ctors_aux>  80482bc:       58                      pop    %eax  80482bd:       5b                      pop    %ebx  80482be:       c9                      leave  80482bf:       c3                      ret<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0430\u0434\u0440\u0435\u0441\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 <code>prog1<\/code>. \u041f\u043e\u0445\u043e\u0436\u0435, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043c\u0435\u0441\u0442\u0438\u043b \u0432\u0441\u0435 \u043d\u0430 28 \u0431\u0430\u0439\u0442. \u0418\u0442\u0430\u043a, \u0437\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u043d\u0430 \u0434\u0432\u0443\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, <code>a_constructor<\/code> (14 \u0431\u0430\u0439\u0442 \u0441 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u043c \u043d\u0443\u043b\u0435\u043c) \u0438 <code>main <\/code>(5 \u0431\u0430\u0439\u0442 \u0441 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u043c \u043d\u0443\u043b\u0435\u043c), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0432\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0438 <code>%s\\n<\/code> (2*4 \u0431\u0430\u0439\u0442\u0430 \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0438\u043c \u043d\u0443\u043b\u0435\u043c). <\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 14+5+4+4 = 27. \u0425\u043c\u043c\u2026\u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442. \u0425\u043e\u0442\u044f \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u044f \u043d\u0435 \u0441\u0442\u0430\u043b. \u041f\u043e\u0437\u0436\u0435 \u043c\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u0435 <code>_do_global_ctors_aux<\/code>, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0448\u0430\u0433 \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435.<\/p>\n<h3><font color=\"#3AC1EF\">\u0410 \u0432\u043e\u0442 \u0438 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d<\/font><\/h3>\n<p>  \u0427\u0438\u0441\u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u0434\u043b\u044f <code>_do_global_ctors_aux<\/code>, \u0432\u0437\u044f\u0442\u044b\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 <code>gcc\/crtstuff.c<\/code> \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <code>gcc<\/code>. <\/p>\n<pre><code class=\"bash\">__do_global_ctors_aux (void) {   func_ptr *p;   for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)     (*p) (); }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043e\u043d \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <code>p<\/code> \u0438\u0437 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>_CTOR_END_<\/code> \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0437 \u043d\u0435\u0435 <code>1<\/code>. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439, \u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0437\u043d\u0430\u0447\u0438\u0442 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>-1<\/code> \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u043d\u0430 \u043e\u0434\u0438\u043d \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0437\u0430\u0434 \u0438\u043b\u0438 \u043d\u0430 4 \u0431\u0430\u0439\u0442\u0430. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u044d\u0442\u043e \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435. <\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>-1<\/code> (\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e), \u043c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043d\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0437\u0430\u0434. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <code>-1<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0434\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0434\u0430\u0436\u0435 0) \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435<\/font><\/h3>\n<p>  \u0412\u043e\u0442 \u043a\u043e\u0434 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u0437 <code>objdump -d<\/code> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443. \u041f\u0440\u0435\u0436\u0434\u0435, \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0430, \u043c\u044b \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e \u043d\u0435\u043c\u0443 \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u043c \u0431\u044b\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435.<\/p>\n<pre><code class=\"bash\">08048450 &lt;__do_global_ctors_aux>:  8048450:       55                      push   %ebp  8048451:       89 e5                   mov    %esp,%ebp  8048453:       53                      push   %ebx  8048454:       83 ec 04                sub    $0x4,%esp  8048457:       a1 14 9f 04 08          mov    0x8049f14,%eax  804845c:       83 f8 ff                cmp    $0xffffffff,%eax  804845f:       74 13                   je     8048474 &lt;__do_global_ctors_aux+0x24>  8048461:       bb 14 9f 04 08          mov    $0x8049f14,%ebx  8048466:       66 90                   xchg   %ax,%ax  8048468:       83 eb 04                sub    $0x4,%ebx  804846b:       ff d0                   call   *%eax  804846d:       8b 03                   mov    (%ebx),%eax  804846f:       83 f8 ff                cmp    $0xffffffff,%eax  8048472:       75 f4                   jne    8048468 &lt;__do_global_ctors_aux+0x18>  8048474:       83 c4 04                add    $0x4,%esp  8048477:       5b                      pop    %ebx  8048478:       5d                      pop    %ebp  8048479:       c3                      ret<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u043b\u043e\u0433<\/font><\/h3>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u043b\u043e\u0433 \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <code>%ebx<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f <code>p<\/code>. \u0412\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434 \u043d\u0435\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0432 \u0441\u0442\u0435\u043a\u0435, \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043c\u044b \u0435\u0433\u043e \u0442\u0430\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e <code>p<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 <code>%ebx<\/code>, \u0430 <code>*p<\/code> \u0432 <code>%eax<\/code>.<\/p>\n<h3><font color=\"#3AC1EF\">\u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043a \u0446\u0438\u043a\u043b\u0443<\/font><\/h3>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0435, \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 <code>_CTOR_END_<\/code> \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e <code>1<\/code> \u0438 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0434\u0430\u043b\u0435\u0435 \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c <code>*(__CTOR_END__ - 1)<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>0x8049f14<\/code>. \u0415\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u044b \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 <code>%eax<\/code> (\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>$0x8049f14<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u044b \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0430 \u0435\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u0435\u0437 <code>$<\/code> \u2014 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430). <\/p>\n<p>  \u0421\u043b\u0435\u0434\u043e\u043c \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 <code>-1<\/code>, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b, \u0442\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u043c \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0430\u0434\u0440\u0435\u0441\u0443 <code>0x8049f14<\/code>, \u0433\u0434\u0435 \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0441\u0442\u0435\u043a, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044f \u0432\u0441\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0434\u0435\u043b\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044f, \u0447\u0442\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>$8049f14<\/code> \u0432 <code>%ebx<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>f<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c <code>xchg %ax,%ax<\/code>.<\/p>\n<p>  \u0427\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a\u043e\u0435? \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 NOP (No OPeration) \u0432 16- \u0438 32-\u0431\u0438\u0442\u043d\u044b\u0445 x86. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u043e\u043d\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0446\u0438\u043a\u043b (\u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u044c \u2013 \u044d\u0442\u043e \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435) \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u043d\u0435 \u0441 <code>8048466<\/code>, \u0430 \u0441 <code>8048468<\/code>. \u0421\u043c\u044b\u0441\u043b \u0437\u0434\u0435\u0441\u044c \u0432 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0446\u0438\u043a\u043b\u0430 \u0441 4-\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0432\u0435\u0441\u044c \u0446\u0438\u043a\u043b \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u044d\u0448\u0430, \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0434\u0432\u0435. \u042d\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u043a\u043e\u0440\u0438\u0442. <\/p>\n<h3><font color=\"#3AC1EF\">\u0418 \u0432\u043e\u0442 \u043c\u044b \u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0446\u0438\u043a\u043b\u0430<\/font><\/h3>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c <code>4<\/code> \u0438\u0437 <code>%ebx<\/code>, \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u044f\u0441\u044c \u043a \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 <code>%eax<\/code>, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 <code>%eax<\/code> \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0441 <code>-1<\/code>. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0440\u0430\u0432\u043d\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u044f \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0446\u0438\u043a\u043b.<\/p>\n<h3><font color=\"#3AC1EF\">\u042d\u043f\u0438\u043b\u043e\u0433<\/font><\/h3>\n<p>  \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u043c \u044d\u043f\u0438\u043b\u043e\u0433\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a <code>_init<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u044d\u043f\u0438\u043b\u043e\u0433\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a <code>_libc_csu_init_<\/code>, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0443\u0436\u0435 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u0430\u0431\u044b\u043b\u0438. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f, \u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430\u2026<\/p>\n<p>  \u041a\u0430\u043a \u044f \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u043c\u044b \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u043e\u0439 <code>prog2<\/code>.<\/p>\n<p>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e <code>gdb <\/code>\u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430.<\/p>\n<pre><code class=\"bash\">$ !gdb gdb prog2 Reading symbols from \/home\/patrick\/src\/asm\/prog2...done. (gdb) set disassemble-next-line on (gdb) b *0x80482b7 Breakpoint 1 at 0x80482b7<\/code><\/pre>\n<p>  \u041c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0435, \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 <code>disassemble-next-line<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0442\u043e\u0447\u043a\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 <code>_init<\/code>, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>_do_global_ctors_aux<\/code>.<\/p>\n<pre><code class=\"bash\">(gdb) r Starting program: \/home\/patrick\/src\/asm\/prog2   Breakpoint 1, 0x080482b7 in _init () => 0x080482b7 &lt;_init+39>: e8 94 01 00 00call   0x8048450 &lt;__do_global_ctors_aux> (gdb) si 0x08048450 in __do_global_ctors_aux () => 0x08048450 &lt;__do_global_ctors_aux+0>: 55push   %ebp<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u044f \u0432\u0432\u0435\u043b <code>r<\/code>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0442\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430. \u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0434\u043b\u044f <code>gdb <\/code>\u0441\u0442\u0430\u043b\u0430 <code>si<\/code>, \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0448\u0430\u0433\u0430, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0443 \u0448\u0430\u0433\u043d\u0443\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u043f\u0435\u0440\u0435\u0434. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u043e\u0448\u043b\u0438 \u0432 <code>_do_global_ctors_aux<\/code>. \u0414\u0430\u043b\u0435\u0435 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0433\u0434\u0430 \u044f \u0431\u0443\u0434\u0442\u043e \u0431\u044b \u043d\u0435 \u0432\u0432\u043e\u0436\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f <code>gdb<\/code>, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u0412\u0432\u043e\u0434\u0430 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u044f \u043d\u0430\u0436\u043c\u0443 \u0412\u0432\u043e\u0434 \u0441\u0435\u0439\u0447\u0430\u0441, \u0442\u043e \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044e <code>si<\/code>.<\/p>\n<pre><code class=\"bash\">(gdb) 0x08048451 in __do_global_ctors_aux () => 0x08048451 &lt;__do_global_ctors_aux+1>: 89 e5mov    %esp,%ebp (gdb)  0x08048453 in __do_global_ctors_aux () => 0x08048453 &lt;__do_global_ctors_aux+3>: 53push   %ebx (gdb)  0x08048454 in __do_global_ctors_aux () => 0x08048454 &lt;__do_global_ctors_aux+4>: 83 ec 04sub    $0x4,%esp (gdb)  0x08048457 in __do_global_ctors_aux ()<\/code><\/pre>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e, \u0441 \u043f\u0440\u043e\u043b\u043e\u0433\u043e\u043c \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438, \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"bash\">(gdb) => 0x08048457 &lt;__do_global_ctors_aux+7>: a1 14 9f 04 08mov    0x8049f14,%eax (gdb)  0x0804845c in __do_global_ctors_aux () => 0x0804845c &lt;__do_global_ctors_aux+12>: 83 f8 ffcmp    $0xffffffff,%eax (gdb) p\/x $eax $1 = 0x80483b4<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0438 \u044f \u0432\u0432\u0435\u043b <code>p\/x $eax<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b <code>gdb <\/code>\u0432\u044b\u0432\u0435\u0441\u0442\u0438 hex-\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 <code>%eax<\/code>. \u042d\u0442\u043e \u043d\u0435 <code>-1<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0446\u0438\u043a\u043b \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0431\u044b\u043b \u0432\u044b\u0432\u043e\u0434, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c <code>si <\/code>\u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u0412\u0432\u043e\u0434\u0430, \u0438 \u043c\u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0435\u0435 \u0432\u0432\u0435\u0441\u0442\u0438.<\/p>\n<pre><code class=\"bash\">(gdb) si 0x0804845f in __do_global_ctors_aux () => 0x0804845f &lt;__do_global_ctors_aux+15>: 74 13je     0x8048474 &lt;__do_global_ctors_aux+36> (gdb)  0x08048461 in __do_global_ctors_aux () => 0x08048461 &lt;__do_global_ctors_aux+17>: bb 14 9f 04 08mov    $0x8049f14,%ebx (gdb)  0x08048466 in __do_global_ctors_aux () => 0x08048466 &lt;__do_global_ctors_aux+22>: 66 90xchg   %ax,%ax (gdb)  0x08048468 in __do_global_ctors_aux () => 0x08048468 &lt;__do_global_ctors_aux+24>: 83 eb 04sub    $0x4,%ebx (gdb)  0x0804846b in __do_global_ctors_aux () => 0x0804846b &lt;__do_global_ctors_aux+27>: ff d0call   *%eax (gdb)  a_constructor () at prog2.c:3 3void __attribute__ ((constructor)) a_constructor() { => 0x080483b4 &lt;a_constructor+0>: 55push   %ebp    0x080483b5 &lt;a_constructor+1>: 89 e5mov    %esp,%ebp    0x080483b7 &lt;a_constructor+3>: 83 ec 18sub    $0x18,%esp<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0437\u0434\u0435\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e. \u041c\u044b \u0448\u0430\u0433\u043d\u0443\u043b\u0438 \u0432 \u0432\u044b\u0437\u043e\u0432 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>a_constructor<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 <code>gdb <\/code>\u0435\u0441\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a \u0421\u0438 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0410 \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u0432\u043a\u043b\u044e\u0447\u0438\u043b <code>disassemble-next-line<\/code>, \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u043d\u0430\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430. <\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043f\u0440\u043e\u043b\u043e\u0433 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u0435\u0433\u043e \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u0420\u0430\u0437\u0432\u0435 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e? \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0443\u0441\u044c \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>n<\/code> (next), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043a\u043e\u0440\u043e \u043f\u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f <code>printf<\/code>. \u041f\u0435\u0440\u0432\u0430\u044f <code>n<\/code> \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442 \u043f\u0440\u043e\u043b\u043e\u0433, \u0432\u0442\u043e\u0440\u0430\u044f <code>printf<\/code>, \u0430 \u0442\u0440\u0435\u0442\u044c\u044f \u044d\u043f\u0438\u043b\u043e\u0433. \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0438 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>gdb <\/code>\u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0433 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438 \u043a\u043e\u043d\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043f\u043e\u0447\u0435\u043c\u0443.<\/p>\n<pre><code class=\"bash\">(gdb) n 4    printf(\"%s\\n\", __FUNCTION__); => 0x080483ba &lt;a_constructor+6>: c7 04 24 a5 84 04 08movl   $0x80484a5,(%esp)    0x080483c1 &lt;a_constructor+13>: e8 2a ff ff ffcall   0x80482f0 &lt;puts@plt><\/code><\/pre>\n<p>  \u041c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0430\u0434\u0440\u0435\u0441 \u0441\u0442\u0440\u043e\u043a\u0438 <code>a_constructor<\/code> \u0432 \u0441\u0442\u0435\u043a \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f <code>printf<\/code>, \u043d\u043e \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 puts, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e <code>puts<\/code>.<\/p>\n<pre><code class=\"bash\"> (gdb) n a_constructor 5} => 0x080483c6 &lt;a_constructor+18>: c9leave      0x080483c7 &lt;a_constructor+19>: c3ret    <\/code><\/pre>\n<p>  \u0420\u0430\u0437 \u043c\u044b \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0442\u043e \u043e\u043d\u0430, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u0432\u044b\u0448\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0432\u043e\u0434 <code>a_constructor<\/code>. \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0441\u043a\u043e\u0431\u043a\u0430 <code>}<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u044d\u043f\u0438\u043b\u043e\u0433\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0435\u0439\u0447\u0430\u0441. \u041a \u0441\u043b\u043e\u0432\u0443 \u043e\u0442\u043c\u0435\u0447\u0443, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>leave<\/code>, \u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u043d\u0430 \u0442\u043e \u0436\u0435, \u0447\u0442\u043e \u0438:<\/p>\n<pre><code class=\"bash\">    movl %ebp, %esp     popl %ebp<\/code><\/pre>\n<p>  \u041e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0448\u0430\u0433 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0441 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u0435\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0417\u0434\u0435\u0441\u044c \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043d\u043e\u0432\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 <code>si<\/code>.<\/p>\n<pre><code class=\"bash\">(gdb) n 0x0804846d in __do_global_ctors_aux () => 0x0804846d &lt;__do_global_ctors_aux+29>: 8b 03mov    (%ebx),%eax (gdb) si 0x0804846f in __do_global_ctors_aux () => 0x0804846f &lt;__do_global_ctors_aux+31>: 83 f8 ffcmp    $0xffffffff,%eax (gdb)  0x08048472 in __do_global_ctors_aux () => 0x08048472 &lt;__do_global_ctors_aux+34>: 75 f4jne    0x8048468 &lt;__do_global_ctors_aux+24> (gdb) p\/x $eax $2 = 0xffffffff<\/code><\/pre>\n<p>  \u041c\u043d\u0435 \u0441\u043d\u043e\u0432\u0430 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0435\u0449\u0435 \u0440\u0430\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043e\u043d \u0440\u0430\u0432\u0435\u043d <code>-1<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043c\u044b \u0432\u044b\u0445\u043e\u0434\u0438\u043c.<\/p>\n<pre><code class=\"bash\">(gdb) si 0x08048474 in __do_global_ctors_aux () => 0x08048474 &lt;__do_global_ctors_aux+36>: 83 c4 04add    $0x4,%esp (gdb)  0x08048477 in __do_global_ctors_aux () => 0x08048477 &lt;__do_global_ctors_aux+39>: 5bpop    %ebx (gdb)  0x08048478 in __do_global_ctors_aux () => 0x08048478 &lt;__do_global_ctors_aux+40>: 5dpop    %ebp (gdb)  0x08048479 in __do_global_ctors_aux () => 0x08048479 &lt;__do_global_ctors_aux+41>: c3ret     (gdb)  0x080482bc in _init () => 0x080482bc &lt;_init+44>: 58pop    %eax<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0441\u043d\u043e\u0432\u0430 \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u0432 <code>_init<\/code>.<\/p>\n<pre><code class=\"bash\"> (gdb)  0x080482bd in _init () => 0x080482bd &lt;_init+45>: 5bpop    %ebx (gdb)  0x080482be in _init () => 0x080482be &lt;_init+46>: c9leave   (gdb)  0x080482bf in _init () => 0x080482bf &lt;_init+47>: c3ret     (gdb)  0x080483f9 in __libc_csu_init () => 0x080483f9 &lt;__libc_csu_init+25>: 8d bb 1c ff ff fflea    -0xe4(%ebx),%edi (gdb) q A debugging session is active.  Inferior 1 [process 17368] will be killed.  Quit anyway? (y or n) y $<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u043b\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a <code>_libc_csu_init<\/code>, \u0438 \u0437\u0434\u0435\u0441\u044c \u044f \u0432\u0432\u0435\u043b <code>q<\/code> \u0434\u043b\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 <code>gdb<\/code>. \u0412\u043e\u0442 \u0438 \u0432\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043e\u0431\u0435\u0449\u0430\u043b. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u0432 <code>_libc_csu_init_<\/code>, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0435\u0449\u0435 \u0441 \u043e\u0434\u043d\u0438\u043c \u0446\u0438\u043a\u043b\u043e\u043c, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0448\u0430\u0433\u0430\u0442\u044c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0433\u043e \u043f\u0440\u043e\u0433\u043e\u0432\u043e\u0440\u044e. <\/p>\n<h3><font color=\"#3AC1EF\">\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 __libc_csu_init__<\/font><\/h3>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u0442\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u043b\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0441 \u0446\u0438\u043a\u043b\u043e\u043c \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u0435\u043d, \u0442\u043e \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u043e\u043c\u0443 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u043a\u0430\u043a \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0421\u0438:<\/p>\n<pre><code class=\"bash\">void __libc_csu_init (int argc, char **argv, char **envp) {    _init ();    const size_t size = __init_array_end - __init_array_start;   for (size_t i = 0; i &lt; size; i++)       (*__init_array_start [i]) (argc, argv, envp); }<\/code><\/pre>\n<p>  <\/p>\n<h3><font color=\"#3AC1EF\">\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0446\u0438\u043a\u043b \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/font><\/h3>\n<p>  \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 <code>_init_<\/code>? \u042f \u0443\u0436 \u0434\u0443\u043c\u0430\u043b, \u0432\u044b \u0438 \u043d\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435. \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u0434. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0434\u0435\u0442 \u043e\u043d \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0438\u0437 <code>_init<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0430 \u043d\u0430\u0448\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b, \u0442\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0442\u0435 \u0436\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e \u0438 <code>main<\/code>.<\/p>\n<pre><code class=\"bash\">void init(int argc, char **argv, char **envp) {  printf(\"%s\\n\", __FUNCTION__); }  __attribute__((section(\".init_array\"))) typeof(init) *__init = init;<\/code><\/pre>\n<p>  \u041c\u044b \u043f\u043e\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 <code>_lib_csu_init<\/code>. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u043a\u0443\u0434\u0430 \u044d\u0442\u043e \u043d\u0430\u0441 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442?<\/p>\n<h3><font color=\"#3AC1EF\">\u041c\u044b \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u0430\u0436 \u043a __libc_start_main__<\/font><\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0448 <code>main<\/code>, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0432 <code>exit()<\/code>.<\/p>\n<p>  <code>exit()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>at_exit<\/code> \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u043e\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0446\u0438\u043a\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <code>fini<\/code>. \u0414\u0430\u043b\u0435\u0435 \u043e\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0446\u0438\u043a\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432. (\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043d\u043e \u043f\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u043c\u043d\u0435, \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0442\u0441\u044f \u043e\u043d\u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435). \u0412\u043e\u0442 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435.<\/p>\n<h3><font color=\"#3AC1EF\">\u042d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, hooks.c, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"bash\">#include &lt;stdio.h>  void preinit(int argc, char **argv, char **envp) {  printf(\"%s\\n\", __FUNCTION__); }  void init(int argc, char **argv, char **envp) {  printf(\"%s\\n\", __FUNCTION__); }  void fini() {  printf(\"%s\\n\", __FUNCTION__); }  __attribute__((section(\".init_array\"))) typeof(init) *__init = init; __attribute__((section(\".preinit_array\"))) typeof(preinit) *__preinit = preinit; __attribute__((section(\".fini_array\"))) typeof(fini) *__fini = fini;  void  __attribute__ ((constructor)) constructor() {  printf(\"%s\\n\", __FUNCTION__); }  void __attribute__ ((destructor)) destructor() {  printf(\"%s\\n\", __FUNCTION__); }  void my_atexit() {  printf(\"%s\\n\", __FUNCTION__); }  void my_atexit2() {  printf(\"%s\\n\", __FUNCTION__); }  int main() {  atexit(my_atexit);  atexit(my_atexit2); }<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 (\u044f \u0437\u043e\u0432\u0443 \u0435\u0435 <code>hook.c<\/code>), \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"bash\">$ .\/hooks preinit constructor init my_atexit2 my_atexit fini destructor $<\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u041a\u043e\u043d\u0435\u0446<\/font><\/h2>\n<p>  \u0415\u0449\u0435 \u0440\u0430\u0437 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0432\u0430\u043c \u0432\u0435\u0441\u044c \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0440\u043e\u0448\u043b\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u0435\u043d.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\"\/><\/div>\n<p>  <a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=Bright_Translate&amp;utm_content=poshagovyj_razbor_zapuska_programmy_v_linux\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ou\/g5\/kh\/oug5kh6sjydt9llengsiebnp40w.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ou\/g5\/kh\/oug5kh6sjydt9llengsiebnp40w.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/588102\/\"> https:\/\/habr.com\/ru\/articles\/588102\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/588102\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_0\/an\/t3\/_0ant3i5gr54psfbqndfw5rdr2g.png\"\/><\/div>\n<p><\/a><\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0432 Linux. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c \u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 ELF x86. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0435\u0449\u0435 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 <code>main<\/code>. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-383051","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/383051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383051"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/383051\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}