x86 Assembly: Data in the Text Section

前端 未结 2 1136
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 21:10

I don\'t quite understand how variables can be stored in the text section and how they can be manipulated. Shouldn\'t all variables be in the .data section and aren\'t all p

2条回答
  •  臣服心动
    2020-12-06 21:52

    Well, the data & code are just bytes. Only how you interpret them makes them what they are. Code can be interpreted as data and vice versa. In most case it will produce the something that's invalid but anyway it's possible.

    Attributes of the section are dependant on the linker and most of them by default make the .text section RO, but it doesn't mean it can't be changed.

    The whole example is a clever way to obtain the address of /bin/sh just by using the call. Basically the call places on the stack the address of the next instruction (next bytes) and in this case it will be the address of this string so pop esi will get that address from the stack and use it.

提交回复
热议问题