Category: Kernel

Assembler Meetup #29, 2020/02/01

Fixed all wrong testcases excepts ptwrite Only 87 wrong instructions are wrong encoding now

2020/02/02 0

Assembler Meetup #28, 2020/01/25

Nothing special, still doing the “jump/call label”, i can get the information (line number & offset) i need

2020/02/02 0

Assembler Meetup #20, 2019/11/09

Kelvin and Jenny heading to encode b* and c* instructions Desmond keep going to PE format Peter try to add assembler marco. I will think about our own linker format next week.

2019/11/09 0

Assembler Dev #19 2019/11/02

We think the encoding method is stable, asked Jenny to write a wiki, describe how we can encode each instruction

2019/11/09 0

Assembler dev meeting #13

2019/09/14, we met in cityu again. I finished IMM in other project . So Assembler’s parser will eat up the whole numeric string and then pass it to antlr-calculator-library, if it contains a maths expression, it return the final answer which is a number. I created another library to produce ELF output. Jenny and…
Read more

2019/09/16 0

ELF Specification 1.2 is only for 32 bits

I am writing a java library to manipulate 64 bits ELF, so i read ELF specification 1.2 , but one big mistake i took is : this specification is only for 32 bits, and the 64 bits one introduce new data types. So I was trying to guess out what data types it is using…
Read more

2019/09/09 0

Assembler dev meeting #11

sync-ed up Jenny coding skill to all of us. Jenny now clearing all useless code, rename variables to a more meaningful name. Our next job is to encode all instructions together, and for me, create an ELF library to output ELF format object code. Here is our tuned assembler grammar

2019/09/01 0

Assembler dev meeting #10

As usual, #10 meeting was hold in CityU. We getting more familiar with Intel basic instruction set translating. Here is the actions list for next week: Zero padding, cut of pad “0” Jenny consolidate your code into well format, let us understand and give us tutorial next sat morning Desmond: nasm in linux example, able…
Read more

2019/08/25 0

Assembler Dev meeting #6, #7 and #8

Desmond typed all basic instructions to grammar. We found some translation are wrong. I fixed the full test so can test all translated instructions.

2019/08/05 0

The 5th Assembler dev meeting

Jenny has done SIB table, Kelvin is working on 66h 67h, Desmond is adding rest of the instructions. Thanks for Professor Ray visiting us and giving us advice.

2019/07/12 0

x86 disassembler預研成功

x86 disassemble預研成功,感謝Rod Pemberton朋友在alt.lang.asm上面的幫忙,原來Intel instruction雖然係CISC但可以在未decode所有Byte之前把Instruction切割出來。還有,切割比我想像人來得簡單。我現在的問題就是,RISC的所謂固定長度指令好像不是傳說中所說的巨大優勢。

2019/07/10 2

4th Assembler dev meeting

We heading into Antlr Grammar, got one problem : We don’t know how anltr prioritise parse rules, so next week will be our study week. A new friend visited us in meetup too.

2019/06/29 0

Assembler encoding test : 16-Bit Addressing Forms with the ModR/M Byte

Code to test “16-Bit Addressing Forms with the ModR/M Byte” // String instruction = “adc byte [ si+0x12], 0x1+0x20x3″; // String instruction = “adc byte [bx+si], 0x1+0x20x3″; // String instruction = “adc byte [bx+di], 0x1+0x20x3″; // String instruction = “adc byte [bp+di], 0x1+0x20x3″; // String instruction = “adc byte [si], 0x1+0x20x3″; // String instruction =…
Read more

2019/01/05 0


Autoconf不能跑得很快的原因是因為它會為每一個feature去compile一個很小的測試程式去測試那個feature能不能被正確編譯出來,在底層系統的世界,因為歷史原故,我們不能好簡單的判斷在你的dev machine裏有libXXX.1.2.3.so就認為你的代碼能正確地編譯出來,因為好多時library的作者更改了代碼但沒有升級版本號。如果要令你的c/c++程式能誇平台編譯,版本號也是沒有絕對意義,因為同一個版本的library在linux和在unix上有着實質的不同。最誇張的例子就是有些庫在linux上是存在,但在unix上是不存在,所以autoconf要為每一次編譯去逐個測試,所以實在快不來,這一點和java/nodejs世界的build system有非常大的不同。

2018/06/17 0

I think there is a bug in Intel Manual

In the intel manual “Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2 (2A, 2B, 2C & 2D): Instruction Set Reference, A-Z”, section 2.1.5, table 2-1, i think it is a bug

2018/05/27 0

What is ISA (Instruction set architecture) ?

From the book Embedded Computing, it has a ISA chapter, below is the summary of “what is ISA” ISA helps compiler’s life easy. Hardware engineer often saving a few gates or some code, but that hurt the design of compiler ISA can both hide and expose key implementation details to the programmer or compiler Process…
Read more

2018/05/22 0

The definition of a toolchain

This book from Shatin Library has a definition of toolchain. A toolchain should contains: Compiler Assembler Libraries Linker Post-link optimizer Run-time program loader simulator Debugger and monitor Automated Test System (Makefile ?) Profiling tools Binary Utilities

2018/05/21 0


寫Assembly用到Marco就試過N次,之前都係用到點就學到邊,無了解過佢嘅邊界,而家差唔多去到要為自己嘅assembler研發marco,所以要先睇下HLA嘅Marco大約可以做到啲乜。沙田圖書館係有唔少好書。 書中講左句: 啲人係用Assembler嘅Marco有幾勁黎判斷個assembler有幾勁,無錯,啲人確實係甘諗。以下就係關於assembler功能上嘅總結: Compile Time Operators. (E.g. : +-*/, <<, >> =, <>) Operator Precedence and Associativity (E.g. : !, -, div, mod) Compile Time Functions Type conversion Numeric functions Character-Classification functions (E.g. : isAlpha, isDigit, isSpace) String functions Symbol information (E.g. : @size, @define @typeName, @elements, @elementSize) Misc compile time functions (E.g. : @odd,…
Read more

2018/05/17 0

Test cases in antlr grammar file

I am developing an Assembler, i think the best way is to embed the test case into the grammer, all those test cases are just one single line of assembly code. But now no way to do this in Antlr grammar. I am thinking to create a maven plugin to pre-process the grammar file. Add…
Read more

2018/02/24 0



2016/06/07 0

a super skill to help you understand .init and .fini

a super skill to help you understand .init and .fini, just do “LD_DEBUG=libs ./a.out”, read detail One thing need to remind you, loader pass control to a.out *BEFORE* it calls the fini.

2016/06/03 0

discovered something about .init and .fini sections

discovered something about .init and .fini sections, if you compile your source file into .o, no .init and .fini sections exist. But if you compile your code into target exe, .init and .fini are there. My question is: where does those .init and .fini come from the .o?

2016/06/02 0

i guess this is the reason i die in exception #0

I die in “divide by zero” exception, when i back trace, it was the destructor of class Vector, i guess the root cause is that: my newlib stub failed to work for the free() function.

2016/05/25 0

finally able to print out the fault address in exception 0 handler

finally able to print out the fault address in exception 0 handler, great step tonight

2016/05/25 0

gcc -O3 will auto remove frame pointer

gcc -O3 will auto remove frame pointer

2016/05/25 0

Pure c exception handler

Pure c exception handler

2016/05/22 0

export a function from gnu assembly to c++

export a function from gnu assembly to c++ then you are free to use it in cpp :

2016/05/22 0

In shit again, c++ built-in function got divide by zero exception

In shit again, c++ built-in function got divide by zero exception

2016/05/16 0

Linux创始人畅谈开源操作系统 Linux创始人林纳斯·托瓦兹(Linus Torvalds)在今年LinuxCon2015会议上的自由提问环节中,向与会者分享了他对开源软件和Linux现状的思考。对开源系统安全性、Linux在物联网中的应用、未来Linux发展蓝图等问题,Torvalds一一做了精彩的回答,eweek、zdnet等媒体都进行了报道。 此次自由提问环节的主持人是Linux基金会的执行董事吉姆·泽姆林(Jim Zemlin)。 像福特一样改造生产力的伟人 主持人Zemlin引用了近期一篇介绍Torvalds的文章作为问答交流环节的开场。Linux操作系统广泛用于现代社会的方方面面,上至卫星火箭,下至成百上千的谷歌服务器。Torvalds作为Linux操作系统的创始人,被认为是继一百年前发明流水线的汽车大王福特以后,再一次通过改进生产工具创造了极大经济效益的影响力人物。Torvalds回应说,自己并没有那样伟大,不过确实很高兴因为开源系统而获得了这些赞誉。可以说,Torvalds在技术上的影响力超过了比尔·盖茨、史蒂夫·乔布斯以及拉里·埃里森,然而Torvalds始终保持谦逊,也可能正是因为这样,他作为Linux领导者的地位始终无法动摇。 缺陷始终存在但并非不安全 接下来Zemlin提了一个关于Linux系统安全性的问题,这个问题自去年开源系统遭遇Heartbleed和Shellshock等漏洞以来备受公众关注。Torvalds解释说,安全共同体常常把问题绝对化,非黑即白。然而在他看来,安全问题只是程序缺陷,基本上都是十分低级的错误。只有当少数极端聪明的人想到利用这些漏洞时,才会造成危害。而在大多数情况下,通常没有人会打这些错误的主意。他强调道,任何软件都不可能彻底没有缺陷。由于有程序缺陷的存在,Linux系统的安全性不可能十全十美。Torvalds同时强调,开源社区对于Linux内核十分谨慎,在加入代码时有着一套严格的标准。只有承认程序缺陷不可避免,才能真正解决安全性问题。唯一的解决方法是多层化,当在某一层发现漏洞后,则在下一层进行修补。无懈可击的系统是不切实际的,问题总是存在,所要做的就是不断完善。 当被问到2015年LinuxCon的热门话题Docker容器时,Torvalds并没有表示出太大的兴趣。他解释说,Linux内核与这些热门的概念没什么关系,作为基础架构者,他只关心人们如何使用内核。 更小、更精致?可能真没办法 目前物联网(IoT)正在蓬勃兴起,作为硬件基础的嵌入式系统大多使用的是Linux操作系统。Torvalds认为,Linux在物联网设备上的瓶颈是其大小不断增长的内核。虽然尝试过开发小而精的物联网设备内核,但是始终难以摆脱不必要的冗余。实际上,Linux内核无法达到像20年前一样的简约规模,但也可以一定程度上地简化缩小。不过Torvalds依然遗憾地告诉大家,如果想要设计出真正精致小巧的设备,只能寻找其他解决方案。 比起未来,更关注现在 最后主持人问到未来十年Linux的前景和计划,Torvalds回答说,他并不会去设想那样遥远的未来。Torvalds自认为是一个“蹒跚的行者”,只会考虑未来六个月的事情。关注于当前的版本发布以及下一版的发布才是理智之举,安排十年后的计划显得十分荒谬。即使让他返回到十年之前,他也没有办法预想今日Linux的成绩。不过,虽然他本人不关注未来十年的发展,但并不是说Linux没有关于未来的愿景。使用开源系统的公司会为未来十年进行规划,它们有着明确的需求,因此在推动自己公司计划的同时也会推动Linux发展。所以Torvalds总结道,就算他本人不是前瞻性的领导者,这整个过程也会促使Linux完成前瞻性的行动。

2016/04/28 0

finally made it: installed the resolver address in GOT[2]

finally made it: installed the resolver address in GOT[2], now i am able to load up elf binary to memory, execute it, during dynamic loading, it jump to GOT[2]. What i have to do is to make my own resolver works.

2016/02/10 0

Description of the first few entries in GOT table

Description of the first few entries in GOT table GOT[0] : The table’ s entry zero is reserved to hold the address of the dynamic structure, referenced with the symbol _DYNAMIC . This allows a program, such as the dynamic linker, to fi nd its own dynamic structure without having yet processed its relocation entries. This is especially…
Read more

2016/02/06 0

My kernel crashed after changed from c to c++

My kernel crashed after changed from c to c++, for this bug, a variable value accidentally changed its value, i was not about to know which code changed it. In previous version of GKD, i can turn on the profiling feature to see which memory address has been accessed, but this is not enough because…
Read more

2016/01/10 1

Running peter-dwarf tutorial

This is the tutorial for running testing program for peter-dwarf, there are two programs inside the jar, first one is a command-line program to test peter-dwarf functions, the second one is a program with GUI. 1) Running the command line program This will print out the function name contain the address 0x1600300 in file “kernel”…
Read more

2016/01/03 0

dwarf is too much for c++

One side effect about changing the kernel from c to c++ is that: in the kernel file, the number of dwarf information will increase dramatically from 1,000 to 1,550,000. This let the peter-dwarf parser work slowing to build a tree to display it (But the dwarf parsing still fast). I added the parameter in PeterDwarfPanel…
Read more

2016/01/02 0

bug that super hard to fix, but i fixed it

!!! Nobody can read the dwarf specification and write the dwarf parser without hacking the binutils lab. Dwarf is just too complex and lots of algorithms in it. Now i can use peter-dwarf to parse out my c++ kernel. The dwarf stub that generated by c++ is *MUCH* more complex the c. fixed these…
Read more

2015/12/16 0

peter-dwarf has bug to decode c++ dwarf file

peter-dwarf has bug to decode c++ dwarf file

2015/12/15 0

Is it a bochs bug? bochs forgets to translate linear addr to physical addr?

Is it a bochs bug? bochs forgets to translate linear addr to physical addr?

2015/11/30 1

describe how to exact bytes from memory

my colleague suggested me to use this method to describe how to exact bytes from memory: using pairs of 2-numbers. The formula is that: So if the formula is “1,2”, then x1 is 1, y1 is 2 . That mean it will exact 1 byte then jump to 2 offset and keep do it repeatedly.…
Read more

2015/11/27 0

Fixed one important bug in grub

I am doing kernel development in mac, my kernel is loaded up by grub because it relay on multiboot spec. I was unable to install grub in a loopback device on mac, so my mac is running a small linux vm in virtual box, i write a simple php to let me upload my kernel,…
Read more

2015/11/14 0