最近在整理书签的时候发现一个奇怪的事情,我使用自己写的包 toc-glue.el 将ToC转换成Lisp的时候发现,使用toc-glue:toc-to-lisp的时候,在调用过一次后它作用的buffer会被固定,即使我修改了当前的ToC buffer,它运行输出的结果也是不变的,重新加载toc-glue.el可以解决此问题,但是再执行一次后内容又会被固定。我一开始怀疑是惰性加载造成的,但是我删掉autoload后手动加载发现还是有这个问题。感觉这应该不是emacs的bug,但是我想不出问题出在哪儿,于是来论坛向各位高手求助。
以下是一个可以用来测试的ToC文件,如果您对此问题感兴趣,可以安装此包后进行测试:
PREFACE 0
1 LINKING AND LOADING 1
1.1 What Do Linkers and Loaders Do? 1
1.2 Address Binding: A Historical Perspective 1
1.3 Linking vs. Loading 5
1.4 Compiler Drivers 10
1.5 Linking: A True-Life Example 12
Exercises 17
2 ARCHITECTURAL ISSUES 19
2.1 Application Binary Interfaces 20
2.2 Memory Addresses 20
2.3 Address Formation 22
2.4 Instruction Formats 23
2.5 Procedure Calls and Addressability 24
2.6 Data and Instruction References 28
2.7 Paging and Virtual Memory 34
2.8 Intel 386 Segmentation 41
2.9 Embedded Architectures 43
Exercises 45
3 OBJECT FILES 47
3.1 What Goes into an Object File? 47
3.2 The Null Object Format: DOS COM Files 49
3.3 Code Sections: UNIX a.out Files 50
3.4 Relocation: DOS EXE Files 56
3.5 Symbols and Relocation 58
3.6 Relocatable a.out 58
3.7 UNIX ELF 62
3.8 IBM 360 Object Format 71
3.9 Microsoft Portable Executable Format 75
3.10 Intel/Microsoft OMF Files 84
3.11 Comparison of Object Formats 90
Exercises 90
Project 90
4 STORAGE ALLOCATION 93
4.1 Segments and Addresses 93
4.2 Simple Storage Layout 94
4.3 Multiple-Segment Types 96
4.4 Segment and Page Alignment 96
4.5 Common Blocks and Other Special Segments 98
4.6 Linker Control Scripts 107
4.7 Storage Allocation in Practice 108
Exercises 114
Project 115
5 SYMBOL MANAGEMENT 117
5.1 Binding and Name Resolution 117
5.2 Symbol Table Formats 118
5.3 Name Mangling 124
5.4 Weak External and Other Kinds of Symbols 129
5.5 Maintaining Debugging Information 129
Exercises 132
Project 133
6 LIBRARIES 135
6.1 Purpose of Libraries 135
6.2 Library Formats 136
6.3 Creating Libraries 141
6.4 Searching Libraries 142
6.5 Performance Issues 144
6.6 Weak External Symbols 144
Exercises 145
Project 146
7 RELOCATION 149
7.1 Hardware and Software Relocation 150
7.2 Link-Time and Load-Time Relocation 151
7.3 Symbol and Segment Relocation 151
7.4 Basic Relocation Techniques 153
7.5 Relinkable and Relocatable Output Formats 159
7.6 Other Relocation Formats 160
7.7 Relocation Special Cases 162
Exercises 163
Project 164
8 LOADING AND OVERLAYS 167
8.1 Basic Loading 167
8.2 Basic Loading, with Relocation 168
8.3 Position-Independent Code 169
8.4 Bootstrap Loading 176
8.5 Tree-Structured Overlays 177
Exercises 184
Project 185
9 SHARED LIBRARIES 187
9.1 Binding Time 188
9.2 Shared Libraries in Practice 190
9.3 Address Space Management 190
9.4 Structure of Shared Libraries 192
9.5 Creating Shared Libraries 192
9.6 Linking with Shared Libraries 197
9.7 Running with Shared Libraries 197
9.8 The malloc Hack and Other Shared-Library Problems 199
Exercises 202
Project 203
10 DYNAMIC LINKING AND LOADING 205
10.1 ELF Dynamic Linking 206
10.2 Contents of an ELF File 206
10.3 Loading a Dynamically Linked Program 210
10.4 Lazy Procedure Linkage with the PLT 213
10.5 Other Peculiarities of Dynamic Linking 215
10.6 Dynamic Loading at Run Time 216
10.7 Microsoft Dynamic-Link Libraries 217
10.8 OSF/1 Pseudo-Static Shared Libraries 222
10.9 Making Shared Libraries Fast 223
10.10 Comparison of Dynamic Linking Approaches 224
Exercises 226
Project 226
11 ADVANCED TECHNIQUES 229
11.1 Techniques for C++ 229
11.2 Incremental Linking and Relinking 233
11.3 Link-Time Garbage Collection 235
11.4 Link-Time Optimization 237
11.5 Link-Time Code Generation 238
11.6 The Java Linking Model 241
Exercises 244
Project 245
REFERENCES 246
INDEX 249
测试步骤:
- 将上面的文件保存为
test.toc - 安装toc-glue.el ,该插件只有单个elisp文件,确保该文件所在路径存在于你的
load-path中即可。 - 打开
test.toc,(require 'toc-glue),然后启用toc-glue-toc-mode - 按下
C-c C-c,可以看到初次运行函数后的的结果。 - 修改该ToC,比如说把第一行的
PREFACE改成PRE,再次按下C-c C-c,发现运行结果还是上一次的结果,PREFACE没有变成PRE。