0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

リンカ・ローダ

各社のリンカ、ローダ、libralian、locator、boot loaderなどの機能を調べる上で、
「リンカ・ローダ実践開発テクニック」 坂井弘亮
は、手がかりをつかめるかもしれない。

リンカ・ローダ実践開発テクニック―実行ファイルを作成するために必須の技術-COMPUTER-TECHNOLOGY-坂井-弘亮
https://www.amazon.co.jp//dp/4789838072/
https://bookmeter.com/books/630946

参考文献にあるLinkers & Loadersは斜め読みしただけで、自分ではこういう道具は作らないだろうと勝手に思っていた。本書では簡易リンカの作成と、道具の作り方まで有るのがすごい。「setjmp()とlongjmp()」というコラムが1頁に入りきらず4頁になっているのに、節にしていないところも興味深い。

<この項は書きかけです。順次追記します。>
This article is not completed. I will add some words in order.

content

content
https://shop.cqpub.co.jp/hanbai/books/38/38071.html

ardump.c リンカ・ローダ実践開発テクニック 坂井弘亮(1) coding(89)
https://qiita.com/kaizen_nagoya/items/2a7bf3050ee6ac662272

binary.c リンカ・ローダ実践開発テクニック 坂井弘亮(2) coding(90)
https://qiita.com/kaizen_nagoya/items/23b985cefc5338677812

combine.c リンカ・ローダ実践開発テクニック 坂井弘亮(3) coding(91)
https://qiita.com/kaizen_nagoya/items/59161e3274270cfd2009

const.c, リンカ・ローダ実践開発テクニック 坂井弘亮(4) coding(92) error(123) docker(174)
https://qiita.com/kaizen_nagoya/items/6f74dbf637a91685d0d1

constructor.c リンカ・ローダ実践開発テクニック 坂井弘亮(5) coding(93)
https://qiita.com/kaizen_nagoya/items/37e14a0943907b6f836f

continue.c リンカ・ローダ実践開発テクニック 坂井弘亮(6) coding(95)
https://qiita.com/kaizen_nagoya/items/e124223fd49db6d9e7a2

down.c リンカ・ローダ実践開発テクニック 坂井弘亮(7) coding(96)
https://qiita.com/kaizen_nagoya/items/866449f129cc8ce4dee7

ctors.c リンカ・ローダ実践開発テクニック 坂井弘亮(8) coding(97)
https://qiita.com/kaizen_nagoya/items/135524de5f8fea10e90f

duplicate.c リンカ・ローダ実践開発テクニック 坂井弘亮(9) coding(123)
https://qiita.com/kaizen_nagoya/items/2339c517f223e556bf67

edata.c リンカ・ローダ実践開発テクニック 坂井弘亮(10) coding(124)
https://qiita.com/kaizen_nagoya/items/bbfe0d6a3c5375026c64

elfread.c リンカ・ローダ実践開発テクニック 坂井弘亮(11) coding(125)
https://qiita.com/kaizen_nagoya/items/600c4a1133dc08da215e

edata.c リンカ・ローダ実践開発テクニック 坂井弘亮(12) coding(126)
https://qiita.com/kaizen_nagoya/items/b6eff6b348d7cf5f257c

hello.c リンカ・ローダ実践開発テクニック 坂井弘亮(13) coding(127)
https://qiita.com/kaizen_nagoya/items/4af05d017d73ebe789d5

inicialize.c リンカ・ローダ実践開発テクニック 坂井弘亮(14) coding(128)
https://qiita.com/kaizen_nagoya/items/4feeb9ef85bfc28fd821

layer.c リンカ・ローダ実践開発テクニック 坂井弘亮(15) coding(129)
https://qiita.com/kaizen_nagoya/items/90bb95f9e538e66d2dbf

ordermain.c リンカ・ローダ実践開発テクニック 坂井弘亮(16) coding(130)
https://qiita.com/kaizen_nagoya/items/446a6768a0abdd13c8b5

N3220 Information technology — Programming languages — C N3220 working draft
https://www.open-std.org/JTC1/SC22/WG14/www/docs/n3220.pdf
N3219 Information technology — Programming languages — C ISO/IEC 9899:2023 DIS Draft
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3219.pdf

layer.c
extern int num;
void printnum();
void func1();
void func2();

int main()
{
  printnum();
  num++;   printnum();
  func1(); printnum();
  func2(); printnum();
  exit (0);
}

次のファイルではstdio.hをincludeしている。

layer2.c
#include <stdio.h>

/* extern int num; */ /* num は localized なので */
void printnum();
void func1();
void func2();

int main()
{
  printnum();
  /* num++;   printnum(); */ /* num は localized なので */
  func1(); printnum();
  func2(); printnum();
  exit (0);
}
layer_sub1.c
#include <stdio.h>

int num = 0;

void printnum()
{
  printf("num = %d\n", num);
}

void func1()
{
  num++;
}
layer_sub2.c
extern int num;

void func2()
{
  num++;
}

Makefileが長い。

Makefile
OBJS=	layer_sub1.o layer_sub2.o liblayer.a liblayer_local.a \
	layer_lib.o layer_lib_local.o layer.o layer2.o \
	layer alayer alayer_local alayer2_local \
	olayer olayer_local olayer2_local \
	layer.exec alayer.exec alayer_local.exec alayer2_local.exec \
	olayer.exec olayer_local.exec olayer2_local.exec \
	liblayer.a.nm liblayer_local.a.nm layer_lib.o.nm layer_lib_local.o.nm \
	layer_lib2.o.comp

all :	$(OBJS)

layer_sub1.o :	layer_sub1.c
	echo "% gcc -c layer_sub1.c -Wall" > layer_sub1.o.comp
	gcc -c layer_sub1.c -Wall >> layer_sub1.o.comp 2>&1
#	echo "% " >> layer_sub1.o.comp

layer_sub2.o :	layer_sub2.c
	echo "% gcc -c layer_sub2.c -Wall" > layer_sub2.o.comp
	gcc -c layer_sub2.c -Wall >> layer_sub2.o.comp 2>&1
#	echo "% " >> layer_sub2.o.comp

liblayer.a :	layer_sub1.o layer_sub2.o
	echo "% ar ruc liblayer.a layer_sub1.o layer_sub2.o" \
		> liblayer.a.comp
	ar ruc liblayer.a layer_sub1.o layer_sub2.o >> liblayer.a.comp 2>&1
	echo "% " >> liblayer.a.comp

liblayer_local.a :	liblayer.a
	echo "% objcopy --localize-symbol=num liblayer.a liblayer_local.a" \
		> liblayer_local.a.comp
	objcopy --localize-symbol=num liblayer.a liblayer_local.a \
		>> liblayer_local.a.comp 2>&1
	echo "% " >> liblayer_local.a.comp

layer_lib.o :	layer_sub1.o layer_sub2.o
	echo "% ld -r layer_sub1.o layer_sub2.o -o layer_lib.o" \
		> layer_lib.o.comp
	ld -r layer_sub1.o layer_sub2.o -o layer_lib.o >> layer_lib.o.comp 2>&1
	echo "% " >> layer_lib.o.comp

layer_lib_local.o :	layer_lib.o
	echo "% objcopy --localize-symbol=num layer_lib.o layer_lib_local.o" \
		> layer_lib_local.o.comp
	objcopy --localize-symbol=num layer_lib.o layer_lib_local.o \
		>> layer_lib_local.o.comp 2>&1
	echo "% " >> layer_lib_local.o.comp

layer_lib2.o.comp :	layer_sub1.c
	echo "% cp layer_sub1.c layer_sub3.c" > layer_lib2.o.comp
	cp layer_sub1.c layer_sub3.c >> layer_lib2.o.comp
	echo "% gcc -c layer_sub3.c" >> layer_lib2.o.comp
	gcc -c layer_sub3.c >> layer_lib2.o.comp
	echo "% ld -r layer_sub1.o layer_sub3.o -o layer_lib2.o" \
		>> layer_lib2.o.comp
	(ld -r layer_sub1.o layer_sub3.o -o layer_lib2.o 2>&1 | cat) \
		>> layer_lib2.o.comp &
	sleep 1
	echo "% " >> layer_lib2.o.comp

layer.o :	layer.c
	echo "% gcc -c layer.c -Wall" > layer.o.comp
	gcc -c layer.c -Wall >> layer.o.comp 2>&1
#	echo "% " >> layer.o.comp

layer2.o :	layer2.c
	echo "% gcc -c layer2.c -Wall" > layer2.o.comp
	gcc -c layer2.c -Wall >> layer2.o.comp 2>&1
#	echo "% " >> layer2.o.comp

layer :	layer.o layer_sub1.o layer_sub2.o
	echo "% gcc layer.o layer_sub1.o layer_sub2.o -o layer" > layer.comp
	gcc layer.o layer_sub1.o layer_sub2.o -o layer >> layer.comp 2>&1
	echo "% " >> layer.comp

alayer :	layer.o liblayer.a
	echo "% gcc layer.o -o alayer -L. -llayer" > alayer.comp
	gcc layer.o -o alayer -L. -llayer >> alayer.comp 2>&1
	echo "% " >> alayer.comp

alayer_local :	layer.o liblayer_local.a
	echo "% gcc layer.o -o alayer_local -L. -llayer_local" \
		> alayer_local.comp
	(gcc layer.o -o alayer_local -L. -llayer_local 2>&1 | cat) \
		>> alayer_local.comp &
	sleep 1
	echo "% " >> alayer_local.comp

alayer2_local :	layer2.o liblayer_local.a
	echo "% gcc layer2.o -o alayer2_local -L. -llayer_local" \
		> alayer2_local.comp
	(gcc layer2.o -o alayer2_local -L. -llayer_local 2>&1 | cat) \
		>> alayer2_local.comp &
	sleep 1
	echo "% " >> alayer2_local.comp

olayer :	layer.o layer_lib.o
	echo "% gcc layer.o layer_lib.o -o olayer" > olayer.comp
	gcc layer.o layer_lib.o -o olayer >> olayer.comp 2>&1
	echo "% " >> olayer.comp

olayer_local :	layer.o layer_lib_local.o
	echo "% gcc layer.o layer_lib_local.o -o olayer_local" \
		> olayer_local.comp
	(gcc layer.o layer_lib_local.o -o olayer_local 2>&1 | cat) \
		>> olayer_local.comp &
	sleep 1
	echo "% " >> olayer_local.comp

olayer2_local :	layer2.o layer_lib_local.o
	echo "% gcc layer2.o layer_lib_local.o -o olayer2_local" \
		> olayer2_local.comp
	gcc layer2.o layer_lib_local.o -o olayer2_local >> olayer2_local.comp &
#	echo "% " >> olayer2_local.comp

layer.exec :	layer
	echo "% ./layer" > layer.exec
	(./layer 2>&1 | cat) >> layer.exec &
	sleep 1
	echo "% " >> layer.exec
	rm -f layer.core

alayer.exec :	alayer
	echo "% ./alayer" > alayer.exec
	(./alayer 2>&1 | cat) >> alayer.exec &
	sleep 1
	echo "% " >> alayer.exec
	rm -f alayer.core

alayer_local.exec :	alayer_local
	echo "% ./alayer_local" > alayer_local.exec
	(./alayer_local 2>&1 | cat) >> alayer_local.exec &
	sleep 1
	echo "% " >> alayer_local.exec
	rm -f alayer_local.core

alayer2_local.exec :	alayer2_local
	echo "% ./alayer2_local" > alayer2_local.exec
	(./alayer2_local 2>&1 | cat) >> alayer2_local.exec &
	sleep 1
	echo "% " >> alayer2_local.exec
	rm -f alayer2_local.core

olayer.exec :	olayer
	echo "% ./olayer" > olayer.exec
	(./olayer 2>&1 | cat) >> olayer.exec &
	sleep 1
	echo "% " >> olayer.exec
	rm -f olayer.core

olayer_local.exec :	olayer_local
	echo "% ./olayer_local" > olayer_local.exec
	(./olayer_local 2>&1 | cat) >> olayer_local.exec &
	sleep 1
	echo "% " >> olayer_local.exec
	rm -f olayer_local.core

olayer2_local.exec :	olayer2_local
	echo "% ./olayer2_local" > olayer2_local.exec
	(./olayer2_local 2>&1 | cat) >> olayer2_local.exec &
	sleep 1
	echo "% " >> olayer2_local.exec
	rm -f olayer2_local.core

liblayer.a.nm :	liblayer.a
	echo "% nm liblayer.a" > liblayer.a.nm
	nm liblayer.a >> liblayer.a.nm
	echo "% " >> liblayer.a.nm

liblayer_local.a.nm :	liblayer_local.a
	echo "% nm liblayer_local.a" > liblayer_local.a.nm
	nm liblayer_local.a >> liblayer_local.a.nm
	echo "% " >> liblayer_local.a.nm

layer_lib.o.nm :	layer_lib.o
	echo "% nm layer_lib.o" > layer_lib.o.nm
	nm layer_lib.o >> layer_lib.o.nm
	echo "% " >> layer_lib.o.nm

layer_lib_local.o.nm :	layer_lib_local.o
	echo "% nm layer_lib_local.o" > layer_lib_local.o.nm
	nm layer_lib_local.o >> layer_lib_local.o.nm
	echo "% " >> layer_lib_local.o.nm

clean :
	rm -f $(OBJS) *.comp

2つのソースから、ソースの違いと動作の違いを説明しようとしている。

関連資料

' @kazuo_reve 私が効果を確認した「小川メソッド」
https://qiita.com/kazuo_reve/items/a3ea1d9171deeccc04da
' @kazuo_reve 新人の方によく展開している有益な情報
https://qiita.com/kazuo_reve/items/d1a3f0ee48e24bba38f1
' @kazuo_reve Vモデルについて勘違いしていたと思ったこと
https://qiita.com/kazuo_reve/items/46fddb094563bd9b2e1e

自己記事一覧

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945
逆も真:社会人が最初に確かめるとよいこと。OSEK(69)、Ethernet(59)
https://qiita.com/kaizen_nagoya/items/39afe4a728a31b903ddc
「何を」よりも「誰を」。10年後のために今見習いたい人たち
https://qiita.com/kaizen_nagoya/items/8045978b16eb49d572b2
Qiitaの記事に3段階または5段階で到達するための方法
https://qiita.com/kaizen_nagoya/items/6e9298296852325adc5e
物理記事 上位100
https://qiita.com/kaizen_nagoya/items/66e90fe31fbe3facc6ff
量子(0) 計算機, 量子力学
https://qiita.com/kaizen_nagoya/items/1cd954cb0eed92879fd4
数学関連記事100
https://qiita.com/kaizen_nagoya/items/d8dadb49a6397e854c6d
統計(0)一覧
https://qiita.com/kaizen_nagoya/items/80d3b221807e53e88aba
図(0) state, sequence and timing. UML and お絵描き
https://qiita.com/kaizen_nagoya/items/60440a882146aeee9e8f
品質一覧
https://qiita.com/kaizen_nagoya/items/2b99b8e9db6d94b2e971
言語・文学記事 100
https://qiita.com/kaizen_nagoya/items/42d58d5ef7fb53c407d6
医工連携関連記事一覧
https://qiita.com/kaizen_nagoya/items/6ab51c12ba51bc260a82
自動車 記事 100
https://qiita.com/kaizen_nagoya/items/f7f0b9ab36569ad409c5
通信記事100
https://qiita.com/kaizen_nagoya/items/1d67de5e1cd207b05ef7
日本語(0)一欄
https://qiita.com/kaizen_nagoya/items/7498dcfa3a9ba7fd1e68
英語(0) 一覧
https://qiita.com/kaizen_nagoya/items/680e3f5cbf9430486c7d
転職(0)一覧
https://qiita.com/kaizen_nagoya/items/f77520d378d33451d6fe
仮説(0)一覧(目標100現在40)
https://qiita.com/kaizen_nagoya/items/f000506fe1837b3590df
音楽 一覧(0)
https://qiita.com/kaizen_nagoya/items/b6e5f42bbfe3bbe40f5d
@kazuo_reve 新人の方によく展開している有益な情報」確認一覧
https://qiita.com/kaizen_nagoya/items/b9380888d1e5a042646b
Qiita(0)Qiita関連記事一覧(自分)
https://qiita.com/kaizen_nagoya/items/58db5fbf036b28e9dfa6
鉄道(0)鉄道のシステム考察はてっちゃんがてつだってくれる
https://qiita.com/kaizen_nagoya/items/26bda595f341a27901a0
安全(0)安全工学シンポジウムに向けて: 21
https://qiita.com/kaizen_nagoya/items/c5d78f3def8195cb2409
一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39
Ethernet 記事一覧 Ethernet(0)
https://qiita.com/kaizen_nagoya/items/88d35e99f74aefc98794
Wireshark 一覧 wireshark(0)、Ethernet(48)
https://qiita.com/kaizen_nagoya/items/fbed841f61875c4731d0
線網(Wi-Fi)空中線(antenna)(0) 記事一覧(118/300目標)
https://qiita.com/kaizen_nagoya/items/5e5464ac2b24bd4cd001
OSEK OS設計の基礎 OSEK(100)
https://qiita.com/kaizen_nagoya/items/7528a22a14242d2d58a3
Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8
++ Support(0) 
https://qiita.com/kaizen_nagoya/items/8720d26f762369a80514
Coding(0) Rules, C, Secure, MISRA and so on
https://qiita.com/kaizen_nagoya/items/400725644a8a0e90fbb0
coding (101) 一覧を作成し始めた。omake:最近のQiitaで表示しない5つの事象
https://qiita.com/kaizen_nagoya/items/20667f09f19598aedb68
プログラマによる、プログラマのための、統計(0)と確率のプログラミングとその後
https://qiita.com/kaizen_nagoya/items/6e9897eb641268766909
なぜdockerで機械学習するか 書籍・ソース一覧作成中 (目標100)
https://qiita.com/kaizen_nagoya/items/ddd12477544bf5ba85e2
言語処理100本ノックをdockerで。python覚えるのに最適。:10+12
https://qiita.com/kaizen_nagoya/items/7e7eb7c543e0c18438c4
プログラムちょい替え(0)一覧:4件
https://qiita.com/kaizen_nagoya/items/296d87ef4bfd516bc394
Python(0)記事をまとめたい。
https://qiita.com/kaizen_nagoya/items/088c57d70ab6904ebb53
官公庁・学校・公的団体(NPOを含む)システムの課題、官(0)
https://qiita.com/kaizen_nagoya/items/04ee6eaf7ec13d3af4c3
「はじめての」シリーズ  ベクタージャパン 
https://qiita.com/kaizen_nagoya/items/2e41634f6e21a3cf74eb
AUTOSAR(0)Qiita記事一覧, OSEK(75)
https://qiita.com/kaizen_nagoya/items/89c07961b59a8754c869
プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945
LaTeX(0) 一覧 
https://qiita.com/kaizen_nagoya/items/e3f7dafacab58c499792
自動制御、制御工学一覧(0)
https://qiita.com/kaizen_nagoya/items/7767a4e19a6ae1479e6b
Rust(0) 一覧 
https://qiita.com/kaizen_nagoya/items/5e8bb080ba6ca0281927
100以上いいねをいただいた記事16選
https://qiita.com/kaizen_nagoya/items/f8d958d9084ffbd15d2a
小川清最終講義、最終講義(再)計画, Ethernet(100) 英語(100) 安全(100)
https://qiita.com/kaizen_nagoya/items/e2df642e3951e35e6a53

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on my individual experience. It has nothing to do with the organization or business to which I currently belong.

文書履歴(document history)

ver. 0.01 初稿  20240714

最後までおよみいただきありがとう4ざいました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?