# EditSegment

## Description

Edit segment attributes. This command opens the Change segment attributes dialog.

![Change segment attributes dialog](/files/FUS7AUapilZLvTcwDcTQ)

## Change segment attributes options

* [How to change segment name](#segment-name)
* [How to change segment class](#class-name)
* [How to change segment addressing mode (16/32)](#segment-bitness)
* [How to change segment alignment](#segment-alignment)
* [How to change segment combination](#segment-combination)

{% hint style="info" %}
Changing the segment class may change the segment type.
{% endhint %}

* **Move Adjacent Segments**: means that the previous and next segments will be shrunk or expanded to fill gaps between segments. Click [here](https://github.com/HexRaysSA/ida-docs/blob/9.3/ida-actions/user-guide/general-concepts/various-dialog-help-messages.md#moving-the-segment-start) for more information.
* **Disable Addresses**: if set, when a segment is shrunk, all information about bytes going out of the segment will be completely removed.. Otherwise, IDA will discard information about instructions/data, comments etc, but will retain byte values so that another segment can be created later and it will use the existing byte values.

If IDA creates 2 segments where only one segment must exist, you may try the following sequence:

* Delete one segment (action `KillSegment`). Choose one with bad segment base value. Do not disable addresses occupied by the segment being deleted.
* Change bounds of another segment. Note that the Create segment... command (action `CreateSegment`) changes the boundaries of the overlapping segment automatically.

Segments with the "debugger" attribute are the segments whose memory contents are not saved in the database. Usually, these segments are created by the debugger to reflect the current memory state of the program.

However, the user can modify this attribute.

If it is cleared, then the segment will permanently stay in the database after closing the debugger session. The database will reflect the state of the segment which was at the time when the status is changed.

If it is set, then the segment will become a temporary segment and will be deleted at the end of the debugging session.

The *debugger segment* checbkox is available only during debugging sessions.

The "loader" segments are the segment created by the file loader. The segment having this attribute are considered to be part of the input file.

A segment with the "debugger" attribute set and the "loader" attribute not set is considered to be an ephemeral segment. Such segments are not analyzed automatically by IDA.

"Segment permissions" group box can be used to modify Segment access permissions (Read/Write/Execute)

### Segment Name

Enter a new name for the segment. A segment name is up to 8 characters long. IDA does check if the length is ok. Try to give mnemonic names for the segments.

### Class Name

The segment class name identifies the segment with a class name (such as CODE, FAR\_DATA, or STACK). The linker places segments with the same class name into a contiguous range of memory in the runtime memory map.

Changing the segment class changes only the segment definition on the screen. There are the following predefined segment class names:

| Segment class | Description                |
| ------------- | -------------------------- |
| CODE          | Pure code                  |
| DATA          | Pure data                  |
| CONST         | Pure data                  |
| BSS           | Uninitialized data         |
| STACK         | Uninitialized data         |
| XTRN          | Extern definitions segment |

If you change segment class and the segment type is "Regular", then the segment type will be changed accordingly.

In order to set the segment type "Regular", you should change the segment class to "UNK".

{% hint style="info" %}
Segment class names are never deleted. Once you define a segment class name, you cannot reuse it as a name of another object.
{% endhint %}

### Segment bitness

You can choose between 16-bit and 32-bit segment addressing.

IDA will delete all instructions and data in the segment if the segment address is changed.

Never do it if you are not sure. It may have irreversible consequences, all instructions/data will be converted to undefined bytes.

### Segment Alignment

You can specify the segment alignment for the selected segment. By default, IDA assumes 'byte' alignment.

Changing the alignment changes only the segment definition on the screen. Nothing else will happen.

### Segment Combination

A field that describes how the linker can combine the segment with other segments. Under MS-DOS, segments with the same name and class can be combined in two ways: they can be concatenated to form one logical segment, or they can be overlapped. In the latter case, they have either the same start address or the same end address, and they describe a common range in memory. Values for the field are:

* **Private**: Do not combine with any other program segment.
* **Public**: Combine by appending at an offset that meets the alignment requirement.
* **Stack**: Combine as for Public. This combine type forces byte alignment.
* **Common**: Combine by overlay using maximum size.

Changing segment combination changes only the segment definition on the screen. Nothing else will happen.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/ida-actions/editsegment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
