0
1

 アプリケーション開発に注力するには

アプリケーション開発に注力するには、下回りが揃っていることが大事。
どんな土台(platform)にもっていっても動かないと意味がない。

Posix系のC言語でいうHosted環境OSは、アプリケーション開発に注力するためのOS。
C言語でいうFreestanding環境は、アプリケーション開発に注力するというよりは、
CPUのハードウェアの能力を最大限に利用するためのプログラムを書いたり、
CPUの能力を最大限に利用するためのFreestanding環境上のOSを記述することができる。

Freestanding環境のOSには、OSEK/VDX OS、それを拡張したAUTOSAR Classic Platform OSがある。
後者は、OSの知識がなくてもアプリケーション開発をできるようにすることと、
Runnable関数をほぼ自動的にTaskに割り当てることにより、タスクの機能をよく知らなくても、
アプリを希望の優先順位で実行できるような仕組みを用意している。

AUTOSAR Classic Platform OSは、半導体会社がCoreメンバになっていない。
当初参加していた半導体会社の仕様のばらつきを反映して、
リンカスクリプト、ローダスクリプトに依存するよりは、
memmap.hの配置によって解決する方法をとっている。

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

リンカ・ローダ

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

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

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

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

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

constructor.c

constructor.c
#include <stdio.h>

void __attribute__((constructor)) init()
{
  printf("init()\n");
}

void __attribute__((destructor)) fini()
{
  printf("fini()\n");
}

int main()
{
  printf("main()\n");
  exit (0);
}

stdio.h をincludeしていることから、Hoosted環境を利用していることが想定できる。
main()と出力して改行して終わる。init(), fini()を出力するかどうかは、言語のImplementation定義か、利用するOSの定義に依存するかもしれない。

main()

see
https://qiita.com/kaizen_nagoya/items/2a7bf3050ee6ac662272

C N3219 4. Conformance
The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any strictly conforming program. A conforming freestanding implementation shall accept any strictly conforming program in which the use of the features specified in the library clause (Clause 7) is confined to the contents of the standard headers <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbit.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and <stdnoreturn.h>. Additionally, a conforming freestanding implementation shall accept any strictly conforming program where:
— the features specified in the header are used, except the following functions: strcoll, strdup, strerror, strndup, strtok, strxfrm; and/or,
— the selected function memalignment from <stdlib.h> is used.
A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.1)
The strictly conforming programs that shall be accepted by a conforming freestanding implementa- tion that defines _STDC_IEC_60559_BFP_ or _STDC_IEC_60559_DFP_ may also use features in the contents of the standard headers <fenv.h>, <math.h>, and the strto* floating-point numeric conversion functions (7.24.1) of the standard header <stdlib.h>, provided the program does not set the state of the FENV_ACCESS pragma to "on".
All identifiers that are reserved when <stdlib.h> is included in a hosted implementation are reserved when it is included in a freestanding implementation.
A conforming program is one that is acceptable to a conforming implementation.2)
An implementation shall be accompanied by a document that defines all implementation-defined and locale-specific characteristics and all extensions.
1)This implies that a conforming implementation reserves no identifiers other than those explicitly reserved in this document.
2)Strictly conforming programs are intended to be maximally portable among conforming implementations. Conforming programs can depend upon nonportable features of a conforming implementation.

5.1.2 Execution environments
5.1.2.1 General
1 Two execution environments are defined: freestanding and hosted. In both cases, program startup occurs when a designated C function is called by the execution environment. All objects with static storage duration shall be initialized (set to their initial values) before program startup. The manner and timing of such initialization are otherwise unspecified. Program termination returns control to the execution environment.
Forward references: storage durations of objects (6.2.4), initialization (6.7.11). 5.1.2.2 Freestanding environment
1 In a freestanding environment (in which C program execution may take place without any ben- efit of an operating system), the name and type of the function called at program startup are implementation-defined. Any library facilities available to a freestanding program, other than the minimal set required by Clause 4, are implementation-defined.
2 The effect of program termination in a freestanding environment is implementation-defined.

main(), stdio, printf()があるからHostedであるとは限らない。

初級実装セミナー教材
https://www.toppers.jp/edu-download.html#edu-begin-download

Freestading Implementation では、startup関数はimplementation definitionである。
mainという名前を定義してもよい。

C言語標準ライブラリのstdio.h, printf関数を定義してもよい。
Full SupportでないことをImplementationとしてDefinitionがあればよい。

attribute

C N36.7.13 Attributes
6.7.13.1 Introduction
In all aspects of the language, a standard attribute specified by this document as an identifier attr and an identifier of the form _attr_ shall behave the same when used as an attribute token, except for the spelling.172)
172)Thus, the attributes [[nodiscard]] and [[_nodiscard_]] can be freely interchanged. Implementations are encour- aged to behave similarly for attribute tokens (including attribute prefixed tokens) they provide.

_attribute_

What does the attribute((force)) do?
https://stackoverflow.com/questions/53120610/what-does-the-attribute-force-do

[C/C++][GCC] attribute((constructor))でmainの前後で処理を実行
https://qiita.com/koara-local/items/c6929054772471bb7d88

5.32 Specifying Attributes of Types
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Type-Attributes.html

Specifying Attributes of Types
https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/specifying-attributes-of-types.html

Unixwiz.net - Software Consulting Central Using GNU C attribute
http://www.unixwiz.net/techtips/gnu-c-attributes.html

表示修正

引用中の<と_ coding(94)
https://qiita.com/kaizen_nagoya/items/707fe7b441bb470d8222

Alt+¥バックスラッシュを入力したら表示しました。ありがとうございました。

URL

502: Bad Gateway
リクエストの処理に時間がかかっています。しばらくしてから再度お試しください。
このページが繰り返し表示される場合は
support@qiita.comまでご連絡ください。
なお、Twitterにて最新の情報を配信しております。

ログインせずにアクセスすると表示する。理由は不明。

関連資料

私が効果を確認した「小川メソッド」
https://qiita.com/kazuo_reve/items/a3ea1d9171deeccc04da

自己記事一覧

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

品質一覧
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

プログラマによる、プログラマのための、統計(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 初稿  20240707

最後までおよみいただきありがとう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